-
17 Apr 2012 4:15 AM #1
Nullable Datetime field not getting rendered in Store (Ext JS)
Nullable Datetime field not getting rendered in Store (Ext JS)
<ext:Store ID="StoreSample" runat="server" RemotePaging="true" RemoteSort="true" AutoLoad="true"
ShowWarningOnFailure="false" >
<Proxy>
<ext:HttpProxy Url="~/Samples/OpenEdit/GetSampleList" Json="true">
</ext:HttpProxy>
</Proxy>
<Reader>
<ext:JsonReader IDProperty="Id" Root="data">
<Fields>
<ext:RecordField Name="Id" Type="Int">
</ext:RecordField>
<ext:RecordField Name="SampleDescription" Mapping="Description">
</ext:RecordField>
<ext:RecordField Name="SamplestartDate" Mapping="StartDate" Type="Date">
</ext:RecordField>
<ext:RecordField Name="SampleEndDate" Mapping="EndDate" Type="Date" >
</ext:RecordField>
</Fields>
</ext:JsonReader>
</ext:Store>In this store the fields SampleStartDate and SampleEndDate are of type Nullabe Datetime (Datetime?) in the model. In controller i am getting value for every field and i am converting this to StoreResult in the function GetSampleList. But in store i am always getting the value as 'undefined' in these two fields. But if i change the datatype from Datetime? to DateTime the in model i am getting all the values in store.Can any one help me to get the nullable datetime value in store?
-
17 Apr 2012 2:11 PM #2
Please try the following code and make any adjustments as needed to simulate your problem:
Regards,Code:Ext.application({ name: 'test', launch: function () { Ext.define('Company', { extend: 'Ext.data.Model', fields: [{ name: 'id', type: 'int' }, { name: 'todate', type: 'date' }] }); Ext.define('Companies', { model: 'Company', extend: 'Ext.data.Store' }); var store = Ext.create('Companies'); store.loadRawData([{ "id": 1, "todate": "2011-08-08" }, { "id": 2, "todate": null }, { "id": 3, "todate": "2011-08-09" }]); var grid = Ext.create('Ext.grid.Panel', { store: store, columns: [{ header: 'Id', dataIndex: 'id' }, { header: 'To', dataIndex: 'todate', xtype: 'datecolumn' }], columnLines: true, width: 600, height: 300, title: 'GRID', renderTo: Ext.getBody() }); } });
Scott.


Reply With Quote