[1.3] Date column on GridPanel

  1. #1

    [1.3] Date column on GridPanel

    I updated from 1.2 to 1.3
    Old JSON (1.2) data is "2012-02-29T10:00:00.123"
    Current JSON (1.3) data is: "\/Date(1296493200000+0700)\/"
    (Get raw data from /Admin/GetData)

    <ext:Store ID="Store" 
        runat="server" 
        WarningOnDirty="true"
        >
            <Proxy>
                <ext:HttpProxy 
                Json="true" 
                Method="POST" 
                Url="~/Admin/GetData/" />
            </Proxy>
    
            <Reader>
                <ext:JsonReader Root="data">
                    <Fields>
                        <ext:RecordField Name="NAME"/>
                        <ext:RecordField Name="DATE"/>
                    </Fields>
                </ext:JsonReader>
            </Reader>
        </ext:Store>
    
        
        <ext:GridPanel ID="GridPanel1" 
                runat="server"
                StoreID="Store"
                Frame="true" 
                Height="570"
                Width="980"
                >
    
                <ColumnModel ID="ColumnModel1" runat="server">
                    <Columns>
                        <ext:Column ColumnID="NAME" Header="NAME" DataIndex="NAME" Sortable="true" Width="200" />
                        <ext:DateColumn ColumnID="DATE" Header="Date" DataIndex="DATE" Sortable="true" Width="95" Format="d/m/Y">
                        </ext:DateColumn >
                    </Columns>
                </ColumnModel>
        </ext:GridPanel>

    My GridPanel Date column currently displayed as "NaN/Nan/0Nan".
    Please help me to fix this.
    Thanks!
    Last edited by quangtt; Mar 09, 2012 at 9:40 AM.
  2. #2
    Hi,

    How looks server side code (/Admin/GetData)?
  3. #3
    Quote Originally Posted by Vladimir View Post
    Hi,

    How looks server side code (/Admin/GetData)?
    *) The GetData action is:
            public ActionResult GetData()
            {
                var query = from h in DBContext.Tests
                            select new
                            {
                                NAME = h.NAME,
                                DATE = h.DATE
                            };
    
                return new AjaxStoreResult(query);
            }
    *) JSON data is:
    {data:[{"NAME":"Name 1","DATE":"\/Date(1325350800000+0700)\/"},{"NAME":"Name 2","DATE":"\/Date(1325437200000+0700)\/"}], total: 0}

    *) Result:
    Click image for larger version. 

Name:	untitled.JPG 
Views:	124 
Size:	12.0 KB 
ID:	3929

    Thanks for kind attension!
  4. #4
    Hi,

    Is Date nullable type (DateTime?) ?
    If yes then try this (return normal date if DATE has a value)
    var query = from h in data
                            select new
                            {
                                NAME = h.NAME,
                                DATE = h.DATE.HasValue ? h.DATE.Value : DateTime.MinValue
                            };
    We fixed it in SVN already, i hope we can release 1.3.1 with this fix soon
  5. #5
    It works well now. Thank you so much!

Similar Threads

  1. Replies: 1
    Last Post: Apr 13, 2012, 1:52 PM
  2. Help on Date Column
    By reezvi in forum 1.x Help
    Replies: 6
    Last Post: Aug 24, 2011, 4:43 PM
  3. Replies: 5
    Last Post: May 23, 2011, 12:13 PM
  4. Replies: 2
    Last Post: May 22, 2011, 1:12 AM
  5. Date column on GridPanel not displaying
    By lionelhutz in forum 1.x Help
    Replies: 0
    Last Post: Nov 16, 2009, 5:47 PM

Tags for this Thread

Posting Permissions