Reputation: 1859
<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?
i am using this store in GridPanel
<Sample:GridPanel ID="GridPanelSample" runat="server" StoreID="StoreSample" Header="false"
AnchorHorizontal="right" AnchorVertical="96%" StandardPager="true" MonitorResize="true" TabIndex="15">
<TopBar>
</TopBar>
<ColumnModel>
<Columns>
<ext:Column runat="server" ColumnID="SampleDescription" Header="Description"
DataIndex="SampleDescription">
</ext:Column>
<ext:DateColumn runat="server" ColumnID="SampleStartDate" Header="StartDate"
DataIndex="SampleStartDate" Format="d MMM Y">
</ext:DateColumn>
<ext:DateColumn runat="server" ColumnID="SampleEndDate" Header="EndDate"
DataIndex="SampleEndDate" Format="d MMM Y">
</ext:DateColumn>
</Columns>
</ColumnModel>
<SelectionModel>
<ext:RowSelectionModel ID="RowSelectionModel1" runat="server" SingleSelect="true"
MoveEditorOnEnter="true">
</ext:RowSelectionModel>
</SelectionModel>
<View>
<ext:LockingGridView runat="server" ID="gridview1" />
</View>
<Listeners>
<ViewReady Handler="openEdit.setOpenEditGridColumnWidths();"></ViewReady>
</Listeners>
</Sample:GridPanel>
But SampleStartDate and SampleEndDate column is always empty
Upvotes: 2
Views: 1797
Reputation: 2385
I think you need to configure the .DateFormat
property of the <ext:RecordField>
.
Example
<ext:RecordField Name="lastChange" Type="Date" DateFormat="M$" />
Setting .DateFormat="M$" will automatically parse the "/Date(123...)/"
value into a JavaScript Date object.
Hope this helps.
Upvotes: 2
Reputation: 1859
Finally i found the solution.
It was because i didn't covert the date type. It was always returning Microsoft AJAX serialized dates (Eg "/Date(1313467512730+0530)/"). This date i need to convert like "2011-08- 15T00:00:00:000". For this i used convert handler.
Code is like
<ext:RecordField Name="SampleStartDate" Mapping="StartDate" Type="Date">
<Convert Handler="return new Date(parseInt(value.substr(6)))" />
</ext:RecordField>
Then i am getting the nullable datetime field values in store.
Hope it will help you also
Thanks
Upvotes: 0