[CLOSED] display milliseconds in GridPanel DateColumn

  1. #1

    [CLOSED] display milliseconds in GridPanel DateColumn

    Hello everyone,

    I can't get my milliseconds to display properly in my DateColumn:

    Column:

    <ext:DateColumn ColumnID="Created" Header="Created" Width="130" DataIndex="Created" Format="dd/MM/yyyy H:mm:ss:u"/>
    Store:

    <ext:RecordField Name="Created" Type="Date" Mapping="Created" />
    The date always displays as 01/01/2011 23:59:59:000 with the milliseconds always as 000, regardless of what is in the data source.

    If I apply the same format to the RecordField, the column doesn't show anything at all.

    My requirement is to be able to sort by Date columns, accurate to the millisecond. Does the GridPanel / Store even support this?
    Last edited by Daniil; Aug 02, 2011 at 1:58 PM. Reason: [CLOSED]
  2. #2
    Hi,

    Milliseconds are lost during data binding from a server.

    I can suggest you the following way.

    Example

    <%@ Page Language="C#" %>
    
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    
    <script runat="server">
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!X.IsAjaxRequest)
            {
                Store store = this.GridPanel1.GetStore();
                store.DataSource = new object[] 
                { 
                    new object[] { DateTime.Now.ToString(@"dd\/MM\/yyyy H:mm:ss:fff") }
                };
                store.DataBind();
            }
        }
    </script>
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title>Ext.Net Example</title>
    </head>
    <body>
        <form runat="server">
            <ext:ResourceManager runat="server" />
            <ext:GridPanel ID="GridPanel1" runat="server" AutoHeight="true">
                <Store>
                    <ext:Store runat="server">
                        <Reader>
                            <ext:ArrayReader>
                                <Fields>
                                    <ext:RecordField Name="test">
                                        <Convert Handler="return Date.parseDate(value, 'd/m/Y G:i:s:u');" />
                                    </ext:RecordField>
                                </Fields>
                            </ext:ArrayReader>
                        </Reader>
                    </ext:Store>
                </Store>
                <ColumnModel runat="server">
                    <Columns>
                        <ext:Column Header="Test" DataIndex="test" Width="300">
                            <Renderer Format="Date" FormatArgs="'d/m/Y G:i:s:u'" />
                        </ext:Column>
                    </Columns>
                </ColumnModel>
            </ext:GridPanel>
        </form>
    </body>
    </html>
    Please note that ExtJS (PHP) format string
    'd/m/Y G:i:s:u'
    is an equivalent of C# format string
    @"dd\/MM\/yyyy H:mm:ss:fff")
  3. #3
    Hello Daniil,

    Thankyou for your reply. While your suggestion does work, it does also mean I'm having to add extra string properties in partial classes for every DateTime property to every single entity in my model which is costing me time and effectively creating UI-specific code in my model, neither of which were my intention to be perfectly honest. Are there any plans to include milliseconds support in the future, given that C#, ASP.net and JavaScript already support them?
  4. #4
    I agree with you, it annoys.

    We will consider it further.

    The problem is JSON.Deserialize() ignores milliseconds by default.

    Example

    <%@ Page Language="C#" %>
    
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    
    <script runat="server">
        protected void Page_Load(object sender, EventArgs e)
        {
            X.Msg.Alert("DateTime", JSON.Serialize(DateTime.Now)).Show();
        }
    </script>
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title>Ext.Net Example</title>
    </head>
    <body>
        <form runat="server">
            <ext:ResourceManager runat="server" />
        </form>
    </body>
    </html>
    Last edited by Daniil; Jul 27, 2011 at 8:48 AM.
  5. #5
    The fix has been added into SVN (revision #3670), please update and re-test.

    How this works fine.

    Example

    <%@ Page Language="C#" %>
     
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
     
    <script runat="server">
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!X.IsAjaxRequest)
            {
                Store store = this.GridPanel1.GetStore();
                store.DataSource = new object[] 
                { 
                    new object[] { DateTime.Now }
                };
                store.DataBind();
            }
        }
    </script>
     
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title>Ext.Net Example</title>
    </head>
    <body>
        <form runat="server">
            <ext:ResourceManager runat="server" />
            <ext:GridPanel ID="GridPanel1" runat="server" AutoHeight="true">
                <Store>
                    <ext:Store runat="server">
                        <Reader>
                            <ext:ArrayReader>
                                <Fields>
                                    <ext:RecordField Name="test" Type="Date" />
                                </Fields>
                            </ext:ArrayReader>
                        </Reader>
                    </ext:Store>
                </Store>
                <ColumnModel runat="server">
                    <Columns>
                        <ext:Column Header="Test" DataIndex="test" Width="300">
                            <Renderer Format="Date" FormatArgs="'d/m/Y G:i:s:u'" />
                        </ext:Column>
                    </Columns>
                </ColumnModel>
            </ext:GridPanel>
        </form>
    </body>
    </html>
  6. #6
    Hi,

    Please follow:
    http://forums.ext.net/showthread.php...ll=1#post82856

    So, you have to set up
    RenderMilliseconds="true"
    for the RecordField.

    Also please note it works with JsonReader only.

Similar Threads

  1. Store Reader DateTime Parsing w/ milliseconds
    By Thinjon100 in forum 1.x Help
    Replies: 2
    Last Post: Nov 20, 2013, 10:03 AM
  2. [OPEN] [#98] GridPanel: date values in DateColumn not localized
    By sbg in forum 2.x Legacy Premium Help
    Replies: 3
    Last Post: Dec 27, 2012, 8:57 AM
  3. display milliseconds in GridPanel DateColumn
    By jimlahey in forum 1.x Help
    Replies: 0
    Last Post: Apr 06, 2011, 8:16 AM
  4. [CLOSED] Renderer does not work on DateColumn in GridPanel
    By Jurke in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Feb 04, 2011, 11:04 AM
  5. [CLOSED] Can a DateColumn be empty in GridPanel?
    By logicspeak in forum 1.x Legacy Premium Help
    Replies: 3
    Last Post: Oct 20, 2010, 12:49 AM

Tags for this Thread

Posting Permissions