PDA

View Full Version : Default Date removal from DatePicker



sencha99999
22 Feb 2012, 2:54 AM
Hi,

Can you one suggest how to remove the default selection of the current date at the initial render of the Datepicker(Calendar) on the screen at runtime, currently it is setting to the default date or any other date i have given, but i want to totally unselect any of the dates in that month.

mitchellsimoens
22 Feb 2012, 5:56 AM
You would have to override the onExpand method of the Date field. Currently it does this:


/**
* @private
* Sets the Date picker's value to match the current field value when expanding.
*/
onExpand: function() {
var value = this.getValue();
this.picker.setValue(Ext.isDate(value) ? value : new Date());
},

You can see it tries to get the value but if the value isn't a date object then it creates a new date object and sets the value to that.

friend
22 Feb 2012, 12:50 PM
After poking through the source code for Ext.picker.Date, it appears that it's heavily geared towards initially showing a date when the picker is expanded, so overriding the class might be a bit of a pain.

Having said that, note that you can call picker.cells.elements[n], where each element represents a 'block' in the picker's UI. All you have to do is remove CSS class 'x-datepicker-today' from the appropriate cell's element and no day will appear to be selected.

GetSet
22 Sep 2015, 5:50 AM
This is the solution that I have found to work in my situation.



listeners: {
//fired one time
boxready: function () {
var box = this;
//remove CSS classes for selected
box.getEl().down('.x-datepicker-selected').removeCls('x-datepicker-today x-datepicker-active x-datepicker-selected');
//reset value
box.value = null;
}
}