View Full Version : Date Picker not populating after override Expand method.

6 Jul 2013, 3:21 AM

I wanted to set different date in date picker by replacing default date of date picker that comes system date.
for that i override Date field - below is my code -


Now i was expecting myDate as default in picker.
But picker is not populating when i click on picker to select date it showing error -

"TypeError: date.getTime is not a function" .

Also i tried - new Date() in place of myDate.

Please let us know what's wrong with my code?

Thank you.

6 Jul 2013, 8:03 AM
Check format (http://docs.sencha.com/extjs/4.2.1/#!/api/Ext.picker.Date-cfg-format) : String (http://docs.sencha.com/extjs/4.2.1/#!/api/String) property of your picker

7 Jul 2013, 10:08 PM

I checked with date format and

I have changed my code according to error - "TypeError: date.getTime is not a function" .

For that i converted date string to date-time as below -

var myDate = new Date("08/07/2013");

Now error is stopped but picker still not populating.


8 Jul 2013, 12:40 AM
You override a base functionality, and of course it's stoped works.
Code below it's a code of expand (http://docs.sencha.com/extjs/4.1.3/#!/api/Ext.form.field.Picker-method-expand)( ) method.
I think at least you need call me.fireEvent('expand', me); and picker.show(); or copy all code of base method and add your code .
But you can use not override method , you can define "expand" method in your components then add your functionality and call this.callParent() function.

expand: function() {
var me = this, bodyEl, picker, collapseIf; if (me.rendered && !me.isExpanded && !me.isDestroyed) { bodyEl = me.bodyEl; picker = me.getPicker(); collapseIf = me.collapseIf; // show the picker and set isExpanded flag picker.show(); me.isExpanded = true; me.alignPicker(); bodyEl.addCls(me.openCls); // monitor clicking and mousewheel me.mon(Ext.getDoc(), { mousewheel: collapseIf, mousedown: collapseIf, scope: me }); Ext.EventManager.onWindowResize(me.alignPicker, me); me.fireEvent('expand', me); me.onExpand(); }

8 Jul 2013, 1:46 AM
Hi Ilay (http://www.sencha.com/forum/member.php?521769-Ilay),

Thank for your answer it work by some modification .. we don't need - me.onExpand(); last line of code becoz it reset date to current date.

I was looking in datefield expand event before that not in picker expand field.

Thank you very much.