2
<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

san
  • 1,859
  • 4
  • 26
  • 38
  • Please post your JS code so we can see what's wrong with it – sha Apr 17 '12 at 12:15
  • Hi Sha Thank you for your reply. "~/Samples/OpenEdit/GetSampleList" is a controller function which convert Model to StoreResult and return to store. I am having all the values in this StoreResult. But when i am trying to use this store in JS i am getting 'undefined' value in the date fields. But if i change the data type of date fields from DateTime? to Datetime in the model it works perfectly and i will be getting all the values in JS. I think problem is with DateTime? datatype – san Apr 17 '12 at 12:41
  • Please post ExtJs code that's not working – sha Apr 17 '12 at 12:47
  • I used this store in GridPanel. I updated my post with the GridPanel code. Thanks – san Apr 17 '12 at 13:05
  • Hi Sha .. I am very much new to Ext JS. Is this the thing you asked? – san Apr 17 '12 at 14:21
  • Not really. Do you have any java script code? – sha Apr 17 '12 at 14:47
  • Thanks Sha for your reply. I got the solution and added the answer below.. – san Apr 18 '12 at 10:51

2 Answers2

2

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.

geoffrey.mcgill
  • 2,375
  • 1
  • 13
  • 21
0

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

san
  • 1,859
  • 4
  • 26
  • 38