Consuming JSON Dates in the EXTJs Mesh Panel

I have an object that converts serialization to a JSON object using JSON.Net. This object is then consumed by the JSON store, which is connected to the ExtJs GridPanel.

All fields except date fields are treated fine, the only way I can display date fields is to use text columns. But then I get the following / Date (1293746400000 + 0200) / rendered as text, which is useless.

I know that I need to somehow convert it to the corresponding date object, but I don't know how to atm.

Let me know if you need more information.

+6
c # extjs
source share
4 answers

JSON.Net has various date and time converters to help you deal with this. See this blog post for some details. This way you can use JavaScriptDateTimeConverter , for example, then convert the result to a JS date object. I can’t remember how Ext will work in the store, but maybe it will point you in the right direction.

+1
source share

The "M $" in the previous example is misleading, its "MS". Here is a clear example that works in extjs 4. The "LastFellOffCliff" field is set to a date with an input 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' ] }); 
+7
source share

Take a look here .

In most cases, you can pass your own formatted string (I use "yyyy-MM-dd" in my projects since I don't need time) and reuse it on the other hand (format it as a valid date constructor).

+1
source share

In the field (s) that is / for a date in your JsonStore, you can set the type of the field "date" and its dateFormat to "M $". Works like a champion.

0
source share

All Articles