Reputation: 1313
I have a UI like this
which uses com.extjs.gxt.ui.client.widget.form.DateField On "change" event of Date i have a listener. The Issue here is
My question is i want to call my code only when the date value is changed without the user need to click outside... is there a way ??
Upvotes: 4
Views: 2878
Reputation: 3832
As long as the user does not leave the widget, no blur-, focus, change-event will be fired. If you are interested in value changes, listen to the keyDown (onKeyDown) event and the TriggerEvent (onTriggerEvent).
Upvotes: 0
Reputation: 21
An easy way to solve the problem is registering ClickEvent for the dateField, dateTextBox in this example:
dateTextBox.addClickHandler(this);
Then fire the change event
public void onClick(ClickEvent event) {
if (event.getSource().equals(datePicker)) {
dateTextBox.setText(DateTimeFormat.getFormat(getDateFormat()).format(datePicker.getValue()));
DomEvent.fireNativeEvent(Document.get().createChangeEvent(), dateTextBox);
datePicker.hide();
}
}
The only thing with this aproach is that clicking on the year/mouth will hide the date picker.
Upvotes: 0
Reputation: 1221
i think you apply listener on datefield.you have to apply listener on datepicker as follow
DateField dateField = new DateField();
dateField.getDatePicker().addListener(Events.Select, new Listener<DatePickerEvent>() {
@Override
public void handleEvent(DatePickerEvent be) {
System.out.println("Selected Date : "+be.getDate());
}
});
i hope it will help you.
Upvotes: 6