[CLOSED] Datecolumn sort issue

  1. #1

    [CLOSED] Datecolumn sort issue

    Hi guys,

    I'm having a grid with a datecolumn populated with an yyyymmdd integer column. I can fix it by setting the dateformat in the modelfield. Filtering is working as expected, but sorting isn't. It sorts on days ...instead of date. Can you help me ?

    <%@ 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)
            {
                this.Store1.DataSource = this.Data;
                this.Store1.DataBind();
            }
        }
    
    
        private object[] Data
        {
            get
            {
                return new object[]
                {
                    new object[] { "3m Co", 71.72, 0.02, 0.03, 20121211 },
                    new object[] { "Alcoa Inc", 29.01, 0.42, 1.47, 20131205 },
                    new object[] { "Altria Group Inc", 83.81, 0.28, 0.34, 20140101 },
                    new object[] { "American Express Company", 52.55, 0.01, 0.02, 20111122 },
               };
            }
        }
    </script>
    
    
    <!DOCTYPE html>
    
    
    <html>
    <head runat="server">
        <title>Simple Array Grid - Ext.NET Examples</title>
        <link href="/resources/css/examples.css" rel="stylesheet" />    
    
    
        <style>
            .x-grid-row-over .x-grid-cell-inner {
                font-weight : bold;
            }
        </style>
    
    
        <script>
            var template = '<span style="color:{0};">{1}</span>';
    
    
            var change = function (value) {
                return Ext.String.format(template, (value > 0) ? "green" : "red", value);
            };
    
    
            var pctChange = function (value) {
                return Ext.String.format(template, (value > 0) ? "green" : "red", value + "%");
            };
        </script>
    </head>
    <body>
        <ext:ResourceManager runat="server" />
        
        <h1>Simple Array Grid</h1>
        
        <ext:GridPanel 
            ID="GridPanel1"
            runat="server" 
            Title="Array Grid" 
            Width="600" 
            Height="350">
            <Store>
                <ext:Store ID="Store1" runat="server">
                    <Model>
                        <ext:Model runat="server">
                            <Fields>
                                <ext:ModelField Name="company" />
                                <ext:ModelField Name="price" Type="Float" />
                                <ext:ModelField Name="change" Type="Float" />
                                <ext:ModelField Name="pctChange" Type="Float" />
                                <ext:ModelField Name="lastChange" Type="Date" DateFormat="yyyymmdd" />
                            </Fields>
                        </ext:Model>
                    </Model>
                </ext:Store>
            </Store>
            <ColumnModel>
                <Columns>
                    <ext:Column runat="server" Text="Company" DataIndex="company" Flex="1" />
                    <ext:Column runat="server" Text="Price" DataIndex="price">                  
                        <Renderer Format="UsMoney" />
                    </ext:Column>
                    <ext:Column runat="server" Text="Change" DataIndex="change">
                        <Renderer Fn="change" />
                    </ext:Column>
                    <ext:Column runat="server" Text="Change" DataIndex="pctChange">
                        <Renderer Fn="pctChange" />
                    </ext:Column>
                    <ext:DateColumn runat="server" Text="Last Updated" DataIndex="lastChange" format="dd-mm-yyyy"/>
                </Columns>            
            </ColumnModel>
            <Features>
                                <ext:GridFilters runat="server" ID="gfIssues" Local="true">
                                    <Filters>
                                        <ext:DateFilter DataIndex="lastChange" AutoDataBind="true">
                                            <DatePickerOptions runat="server" Format="dd-mm-yyyy" TodayText="Now" />
                                        </ext:DateFilter>
                                    </Filters>       
                                </ext:GridFilters>
            </Features>
            <SelectionModel>
                <ext:RowSelectionModel runat="server" />
            </SelectionModel>
            <BottomBar>
                <ext:Toolbar runat="server">
                    <Items>
                        <ext:Button runat="server" Text="Print" Icon="Printer" Handler="this.up('grid').print();" />
                    </Items>
                </ext:Toolbar>
            </BottomBar>
        </ext:GridPanel>
    </body>
    </html>
    Last edited by Daniil; Apr 03, 2014 at 2:47 AM. Reason: [CLOSED]
  2. #2
    Hi Martin,

    I cannot reproduce or don't understand what I should reproduce. I clicked the column header and the dates appear in correct orders for me. I attached the screenshots.
    Click image for larger version. 

Name:	Asc.JPG 
Views:	23 
Size:	11.9 KB 
ID:	9101Click image for larger version. 

Name:	Desc.JPG 
Views:	21 
Size:	11.9 KB 
ID:	9111

    What are the results on your side?
  3. #3
    Quote Originally Posted by Daniil View Post
    Hi Martin,

    I cannot reproduce or don't understand what I should reproduce. I clicked the column header and the dates appear in correct orders for me. I attached the screenshots.
    Click image for larger version. 

Name:	Asc.JPG 
Views:	23 
Size:	11.9 KB 
ID:	9101Click image for larger version. 

Name:	Desc.JPG 
Views:	21 
Size:	11.9 KB 
ID:	9111

    What are the results on your side?
    mmmm..you're right. Not sharp yesterday I pressume. I experience another problem though. And that's a strange one. If you change the input into 20140331 the grid shows 01-03-2014 .. but the other dates are still correct. Any idea ?

    Martin
  4. #4
    Oh, "mm" - it is minutes. You should use "MM" for months.
    <ext:ModelField Name="lastChange" Type="Date" DateFormat="yyyyMMdd" />
    <ext:DateColumn runat="server" Text="Last Updated" DataIndex="lastChange" Format="dd-MM-yyyy" />
  5. #5
    oops..

    Thanks for pointing that out :(

Similar Threads

  1. Ext.Net.DateColumn Format issue
    By lmueller in forum 1.x Help
    Replies: 4
    Last Post: Sep 17, 2018, 4:05 AM
  2. Replies: 8
    Last Post: Dec 21, 2012, 6:42 AM
  3. Replies: 4
    Last Post: Jul 25, 2011, 4:57 PM
  4. GridPanel - Sort Issue
    By lucas in forum 1.x Help
    Replies: 1
    Last Post: Nov 29, 2010, 3:58 PM
  5. Sort with Conditional sort direction in JS- help!
    By Tbaseflug in forum 1.x Help
    Replies: 2
    Last Post: May 05, 2009, 12:11 PM

Posting Permissions