PDA

View Full Version : [FIXED] datepickerfield with picker freez the app



moisan.j
13 Nov 2012, 3:26 AM
Ext version tested:

Sencha Touch 2.1.0
Browser versions tested against:

Chrome 20.0.1132.47 m
DOCTYPE tested against:

<!DOCTYPE HTML>
Description:

When trying to choose a date in datepickerfield, navigator freez and don't respond
Steps to reproduce the problem:

Application is a Sencha MVC application
Just add this code in anyone forms view:

{ xtype: "datepickerfield",
label: "date",
margin: "1.2em 0em 0em 0em",
dateFormat: "d/m/Y",
picker: {
yearFrom: Ext.Date.format(Ext.Date.add(new Date(), Ext.Date.YEAR, -10), "Y"),
yearTo: Ext.Date.format(Ext.Date.add(new Date(), Ext.Date.YEAR, 20), "Y")
},
action: "dluoMin"
}
The result that was expected:

datepicker must show taking care of year initialization in picker
The result that occurs instead:

navigator freez.
Test Case:
To reproduce go on: http://docs.sencha.com/touch/2-1/#!/api/Ext.field.DatePicker
(http://docs.sencha.com/touch/2-1/#!/api/Ext.field.DatePicker)In the codeEditor of example add below code to datepickerfield configuration:

picker: { yearFrom: Ext.Date.format(Ext.Date.add(new Date(), Ext.Date.YEAR, -10), "Y"),
yearTo: Ext.Date.format(Ext.Date.add(new Date(), Ext.Date.YEAR, 20), "Y")
},

INFORMATIONScreenshot or Video:

/
See this URL for live test case: http://Debugging already done:

/
Possible fix:

/
Additional CSS used:

/
Operating System:

WinXP Pro

mitchellsimoens
13 Nov 2012, 5:50 AM
The reason for this is yearFrom/yearTo expect an integer where you are providing a string.


Ext.Date.format(Ext.Date.add(new Date(), Ext.Date.YEAR, -10), 'Y') === '2002'

So you can work around it currently by doing this:


{
xtype : 'datepickerfield',
label : 'date',
margin : '1.2em 0em 0em 0em',
dateFormat : 'd/m/Y',
picker : {
yearFrom : parseInt(Ext.Date.format(Ext.Date.add(new Date(), Ext.Date.YEAR, -10), 'Y')),
yearTo : parseInt(Ext.Date.format(Ext.Date.add(new Date(), Ext.Date.YEAR, 20), 'Y'))
},
action : 'dluoMin'
}

Now I think we can do the parseInt in the framework to protect things if we can so I will open as a bug.

moisan.j
14 Nov 2012, 8:08 AM
That's wkorking fine, well done, Big Thank.