PDA

View Full Version : Clear a DateField?



mdutra
2 Feb 2010, 8:05 AM
I have a site that a user will be entering date ranges. The site is multilingual and the language/date format is set by an administrator. Due to this I can find no "good" way to validate when a user enters, for example, 01/07/2009 if they mean Jan 7 or July 1. To remove this issue I made the requirement that the user must use a calendar control of some sort. I would like to use the DateField but if I make it editable: false I do not see a clean way to give the user the ability to clear out the date field. Is there some way that I am missing or is the best way to override the "Today" button to be a clear button?

rbastic
5 Feb 2010, 8:31 AM
What if you add an additional "Clear Fields" button that would empty the value?

The button handler should probably be something like yourDateField.reset();

Cheers

mdutra
5 Feb 2010, 8:42 AM
Oh, outside of the datefield altogether? I suppose I would have to add a button on both fields to allow them to be cleared individually. I am worried that it may not be clear what those buttons do if I make them small such as a red x, but if I actually have text in them that says "Clear field" then I will be taking up a lot more room and the interface will look crappy. No way to create anything inside the datepicker?

aconran
5 Feb 2010, 10:47 AM
Yes, you could update the today button to use the text "Clear" and reset the calendar control.

Take a look at Ext.DatePicker which is used by the Ext.form.DateField.

You will want to set todayText to "Clear" and override the selectToday handler to reset the value instead of set it.

Webtel
15 Nov 2011, 4:02 AM
you can input date by hand but you cant clear it. it shold be out of the box functionality efter edit if rawValue == '' value = null .

Does anybody got working override?

softm
20 Nov 2011, 3:34 PM
i have same problem, current;ly added context menu - to select which datefield to clear ... but am searching for solution, - to add another button at the bottom of calendar control.

Here are some answers (http://stackoverflow.com/questions/8191285/extjs-sencha-add-button-to-datefield-popup-to-clear-date/8193992#8193992), maybe this will help, but i currently don't have answer ... if anybody find howto add reset button at datefield calendar pop - pls help me.