PDA

View Full Version : Multi-type grid cell: how to preserve date format



mike1993
20 Apr 2017, 9:31 AM
I have a grid with multiple types (set with renderer and getEditor). if the filed is a Date, the format of the displayed date changes after new date is selected from '2017-04-20' to smth like 'Wed Apr 20 2017 00:00:00 GMT (Eastern Daylight Time)'
and the value sent to server is '2017-04-20T00:00:00' on save.

I created the fiddle with sample code. I am not really familiar how to emulate saving to the server so I removed the code



handler: function() {
var recs = grid.getStore().getModifiedRecords();
if (recs && recs.length > 0) {
grid.getStore().sync({
success: function() {
Ext.MessageBox.alert('Success!', 'Outage Status Configuration has been updated.');
}
});
}
}


https://fiddle.sencha.com/#view/editor&fiddle/1uak


what am I missing? how do I preserve the date format?

Thank you!

mike1993
2 May 2017, 6:42 AM
solved by adding a listener


listeners: {
edit: function (editor, context, eOpts) {
if (context.record.get('type') === 'ValueDate') {
var newVal = Ext.Date.format(context.value, 'Y-m-d');
context.record.set('value', newVal);
}
}
},