lundi 5 mai 2014

Ext.field.DatePicker override month slot text to show month number

I am sporadically getting this to work on my local machine when viewing in chrome, but when running this on PhoneGap on an ios device, it reverts back to showing month names. Wondering if anybody had any insight. Seems like some sort of race condition when the slot gets generated.

Thanks,

Steve



Code:



Ext.define('App.view.Settings', {
extend: 'Ext.Panel',
config: {
items:[
{
xtype: 'datepickerfield',
itemId:'ccExpiration',
dateFormat: 'n - Y',
placeHolder: '',
picker: {
slotOrder: [
'month',
'year'
],


doneButton: 'Ok',
cancelButton: 'Cancel',
value: (new Date()), // Set date to now
yearFrom: new Date().getFullYear(),
yearTo: new Date().getFullYear() + 10, // 10 yrs from now
// Override the date picker so that we can display month number instead of name
createSlot: function(name, days, months, years) {
switch (name) {
case 'year':
return {
name: 'year',
align: 'center',
data: years,
title: this.getYearText(),
flex: 3
};
case 'month':
for(var i in months){
console.log(i)
months[i].text = months[i].value;
}
return {
name: name,
align: 'right',
data: months,
title: this.getMonthText(),
flex: 4
};
}
}
}
}
]
}
});




Aucun commentaire:

Enregistrer un commentaire