I want to override the datefield format depending on the country I am coming in from. I have written the following function, and then used the Ext.Loader.loadScript to apply this.But this is not overriding the datefield format. I am implementing this in ExtJS 4.Can someone suggest me how I can override the datefiled format. Thank you :)
function fnc() {
switch (params.country) {
case 'USA':
Ext.override(Ext.form.DateField, {
format : 'm/d/Y'
});
Ext.override(Ext.grid.DateColumn, {
format : 'm/d/Y'
});
Ext.override(Ext.picker.Date, {
format : 'm/d/Y'
});
break;
case 'MEX':
Ext.override(Ext.form.DateField, {
format : 'd/m/Y'
});
Ext.override(Ext.grid.DateColumn, {
format : 'd/m/Y'
});
Ext.override(Ext.picker.Date, {
format : 'd/m/Y'
});
break;
default:
Ext.override(Ext.form.DateField, {
format : 'm/d/Y'
});
Ext.override(Ext.grid.DateColumn, {
format : 'm/d/Y'
});
Ext.override(Ext.picker.Date, {
format : 'm/d/Y'
});
break;
};
}
Its working now, Added the following in the launch function in app.js at the start,
Ext.Loader.loadScript({url:URL,onLoad:function(){
debugger;
var dateObj = {};
dateObj.format = "";
switch(country) {
case "USA":
dateObj.format = "m/d/Y";
break;
case "MEX":
dateObj.format = "d/m/Y";
break;
default: // USA, etc.
dateObj.format = "m/d/Y";
}
Ext.override(Ext.form.field.Date, dateObj);
}
});
And dont specify any format in the field definition,