Why doesn't the ng-lightning datepicker fire a (change) event when selecting a date? - ng-lightning

I'm using Angular 9 and ng-lightning 7. I'm trying to use the ngl-datepicker-input component, but I'm having trouble having it behave how I want. The effect I'd like to achieve is to have a save() method be invoked EITHER:
When a date is selected in the datepicker popup window
When the user is done making changes to the input box (ie: the Angular (change) event binding for an input box)
However, it seems like the ngl-datepicker-input (https://ng-lightning.github.io/ng-lightning/#/components/datepickers) only provides the (valueChange) EventEmitter. This fires when the user selects a date in the datepicker popup window (ok for me) but it also fires on every keystroke into the input box (NOT ok for me). I don't want to save() until the user is done with editing.
I tried using just an ordinary (change) event binding on the input like below. This works very well for any user interactions with the input box. However, selecting a date out of the input box does not fire the (change) event, so I'm not able to capture those changes.
<ngl-datepicker-input
format="middle-endian"
[openOnInputClick]="false"
[class.slds-has-error]="!model.valid"
[(ngModel)]="checkpointDate"
#model="ngModel">
<input nglDatepickerInput type="text" (change)="save()">
</ngl-datepicker-input>
How can I either:
Use the (change) event binding on the input box, and then separately handle changes emitted by ONLY the datepicker popup window?
Allow selections in the datepicker popup window to also trigger a (change) event in the input box?

Related

Detecting a selection of a old value with mouse

When i click on an <input type=text>, a list of old values appear. If I chose one of them with the mouse, the event "change" from jQuery doesn't trigger.
What event should/could I use to detect this?
You have to use oninput event, using jquery:
$('#myinput').on('input',function(){
//your code here
});
change will only trigger if field loose it's focus (blur event). And the term old values appear is browser feature that remembers form data for fields with same name. You can not trigger change event with that. You need an alternate event like paste , input.
$("#field").on("input DOMAttrModified paste",function(){
});
I'm not sure of event. You can try some though.

kendo ui combobox data-value-change parameter not working

I'm using Kendo UI and using declarative bindings to binda element on a form. It uses the combo box widget to search for a list of options. The widget is actually performing as expected, however the search is only requested when the value has changed (this makes sense). The issue I have is the change event is only firing when the user blurs the combo box (e.g. by clicking outside the input).
This is to be expected due to the DOM change event firing after blurring, however the Kendo UI docs state that by using the 'data-value-update' parameter you can specify the event to fire on 'keyup'.
Unfortunately I cannot get this to work, here is the combobox HTML
<input data-role='combobox' data-bind="value: comboBoxValue, events: { change: methodToDoSearch}" data-value-update="keyup" type="text" data-text-field='Text' data-value-field='Id' />
This is being created as part of a kendo ui template (although I have tested outside of the template so this should not make a difference)
Thanks in advance.
The data-value-update attribute is supported only for vanilla textboxes (<input type="text" />). Kendo ComboBox raises its change event only when it loses focus.
Specifically, the data-value-update is only meant to update the bound object the widget is applied to (when you enter something into the widget, the observable is updated with the value on the given event. In this case, keyup).
I.E., because the combobox widget can only be set to one of the combobox datasource values, it doesn't make sense for the observable to bind to a temporary non-combobox-value.
I haven't tried this, but what events can you bind to via the events binding? The Kendo demos show mouseover, click, etc. Perhaps try something like this:
<input data-role='combobox' data-bind="value: comboBoxValue, events: { change: methodToDoSearch, keyup: methodToDoSearch}" type="text" data-text-field='Text' data-value-field='Id' />
In general, what event do you want to fire on keyup? If you'd like to do some manual searching to change the datasource of the combobox on keyup, that's what I'd look in to.

LostFocus method of a text box getting executed before Form_Unload

I am currently programming in MS Access VBA. I have a form with a textbox on it. I am executing some code on LostFocus event of the textbox.
However, when I close the form using mouse and by clicking on close button on right-top corner of the form, with cursor in the text box, I have noticed that LostFocus event is getting executed before Form_Unload event.
Is there a way to avoid this?
Also, where can I find priorities of the events?? Or How are priorities decided in VBA?
EDIT:
My exact application is like this.
I have a form in MS Access which is used for accepting users' login credentials.
I want to disble textbox for Password and Login button till a valid Username is entered. I check if the username is valid or not on onLostFocus event. Now, consider a case where this form is closed without entering anything in Username textbox. In that case, onLostFocus event gets executed before Form_Unload event.
However, for normal operation, I require onLostFocus event because, on that event I enable Password textbox and login button.
Could there be a different way of doing it??
The lost focus event is not usually the best event for code. Did you have a specific reason for using it? If so, you will need to add a condition to the execution.
The order of events for an Access form are:
Exit → LostFocus
If you are closing a form, the Exit and LostFocus events occur before
the events associated with closing the form (such as Unload,
Deactivate, and Close), as follows:
Exit (control) → LostFocus (control) → Unload (form) → Deactivate
(form) → Close (form)
-- http://office.microsoft.com/en-ie/access-help/order-of-events-for-database-objects-HP005186761.aspx
"I check if the username is valid or not on onLostFocus event."
Do your validation in the after update event of the username text box ... enable/disable the password text box as appropriate when the username value changes.
You can initially disable the the password text box at form load, assuming the form loads with the username text box empty.
using onDirty or onChange is probably better for what you're doing if it is a control that you're inserting data into. There's a bunch of better choices than onLostFocus. Without knowing anything specific makes it tough to know how to help you more specifically. I'd say just try another on Event, because due to the nature of onLostFocus, it'd be impossible to prepare for this contingency.

On activate does not fire with my Modal/Pop-Up form to Requery

I have a modal/pop-up form frmEditContact open
on this form there is a combo box full of addressescmbAddressList, populated by a query.
when the user wants to add an address that doesn't exist there is a button that opens the frmAddress where they may add an address.
frmAddress allows them to enter an address to the list and gives the option to save, or cancel (both actions close the form after). with this form closed, the focus is now again on frmEditContact
I would like to repopulate the combo box using docmd.Requery cmbAddressList after they close the other form
I'm not sure where to handle this, I've tried On Avtivate, On Load, On Update, On Open, On Focus...but none of them fire as I keep the frmEditContact open when they are using the other form
is there a way to keep frmEditContact open the whole time, but still an action Event that will fire so that I can Requery? And does On Activate not work with modal forms?
You can requery the combo from frmAddress :
Forms!frmEditContact.cmbAddressList.Requery
I suggest you use the save button to run the requery.
Try this in your frmEditContact code.
DoCmd.OpenForm "frmAddress", acNormal, WindowMode:=acDialog
Me.cmbAddressList.Requery
Since frmAddress is opened in dialog mode, the next line (Requery) will not run until after frmAddress is closed.

windows form validation issues (.net2.0 )

I need help with some things regarding windows form validation:
closing form using standard form closing button (X) triggers validation of all controls.
Is there a way to supress it when closing form using this button, and force it only when pressing my own button?
validation of textbox (possibly other controls, I tested only textboxes) wont invoke when i change text (value) programatically. I need to type text directly into textbox if I want validation to be triggered later, before form is closed. How to tell the form that some control needs validation (but not to trigger it immedidately)?
Thanks.
EDIT:
(1) solved, using this answer.
(2) now, after i set AutoValidate property to false and added ValidateChildren() to my button, only 1 control is being validated with its current value, values of all other controls are revert to value binded to them from DataSource object . I checked it in Validating event - only first control validating keeps its current value, after this validation is finished, other controls' values are replaced with values from DataSource object. I don't understand why. Any clues?
Try this, maybe it could help you. ( for 1)
In the Forms Load event you can put
this.ControlBox = false;. This will hide your X button with the other buttons at the top.
The Form has a Form1_FormClosing event. In that Event you could call the triggers you need. Put a button on the form, and in button_Click event you type this.Close().