I have a object that im serializing to a JSON object using JSON.Net. This object is then being consumed by a JSON Store which is attached to a ExtJs GridPanel.
All fields except date fields render fine , the only way i can render date fields is if i use text columns. But then i get the following /Date(1293746400000+0200)/ rendered as text which is useless.
I know i need to convert that somehow to a proper date object but i have not idea how atm.
Let me know if you need more info.
"M$" in the preceeding example is misleading, its "MS". Here is a clear example that works in extjs 4. The 'LastFellOffCliff' field is set to be a date with incoming format in the Microsoft JSON date style: "/Date(...)/"
Ext.define('ACME.model.CoyoteModel', {
extend: 'Ext.data.Model',
fields: [
{ name: 'CoyoteID', type: 'int' },
'Nickname',
{ name: 'LastFellOffCliff', type: 'date', dateFormat: 'MS' },
'Notes'
]
});
JSON.Net has various date/time converters to help you deal with this. See this blog post for some details. So you could use the JavaScriptDateTimeConverter
for example, then eval the result into a JS date object. I can't recall off the top of my head how an Ext store will deal with that, but maybe it will point you in the right direction.
Have a look at here.
In most cases you can pass your own formatted string (i use "yyyy-MM-dd" in my projects as i don't need time) and re-use it on the other side (format it as a valid date constructor).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With