The official release of Ext.NET Mobile is now available. Ext.NET Mobile is an ASP.NET component framework for building Phone and Tablet specific mobile web applications. Read More

GridPanel sorting null values - bad order

  1. #1

    GridPanel sorting null values - bad order

    Hi,
    sorting GridPanel - null values are not sorted, empty values - are sorted OK.
    Example:
    before sort
    COLUMN1
    value3
    null
    value1


    after sorting COLUMN1 ASC, it becomes:
    COLUMN1
    value1
    null
    value3

    null stays untouched, usually user expects :
    COLUMN1
    null
    value1
    value3
  2. #2

    RE: GridPanel sorting null values - bad order

    Hi gercas,

    I modified the ArrayGrid sample to include 'null' values, although sorting appears to work as expected.

    Example

    <%@ Page Language="C#" %>
    
    <%@ Register Assembly="Coolite.Ext.Web" Namespace="Coolite.Ext.Web" TagPrefix="ext" %>
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    
    <script runat="server">
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Ext.IsAjaxRequest)
            {
                this.Store1.DataSource = new object[]
                {
                    new object[] { "3m Co", "Item1" },
                    new object[] { "Alcoa Inc", null },
                    new object[] { "Altria Group Inc" },
                    new object[] { "American Express Company", "Item4" },
                    new object[] { "American International Group, Inc.", "Item5" },
                    new object[] { "AT&amp;T Inc.", "Item6" },
                    new object[] { "Boeing Co.", "Item7" },
                    new object[] { "Caterpillar Inc.", "Item8" },
                    new object[] { "Citigroup, Inc.", null }
                };
    
                this.Store1.DataBind();
            }
        }
    </script>
    
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head id="Head1" runat="server">
        <title>Simple Array Grid - Coolite Toolkit Example</title>
    </head>
    <body>
        <form id="form1" runat="server">
            <ext:ScriptManager ID="ScriptManager1" runat="server" />
            
            <ext:Store ID="Store1" runat="server">
                <Reader>
                    <ext:ArrayReader>
                        <Fields>
                            <ext:RecordField Name="company" />
                            <ext:RecordField Name="item" Type="String" />
                        </Fields>
                    </ext:ArrayReader>
                </Reader>
            </ext:Store>
            
            <ext:GridPanel 
                ID="GridPanel1" 
                runat="server" 
                StoreID="Store1" 
                StripeRows="true"
                Title="Array Grid" 
                TrackMouseOver="true"
                Width="600" 
                Height="350"
                AutoExpandColumn="Company">
                <ColumnModel runat="server">
                    <Columns>
                        <ext:Column ColumnID="Company" Header="Company" Sortable="true" DataIndex="company" />
                        <ext:Column ColumnID="Item" Header="Item" Sortable="true" DataIndex="item" />
                    </Columns>
                </ColumnModel>
            </ext:GridPanel>          
        </form>
    </body>
    </html>
    Can you modify the above sample, or include a different code sample which demonstrates how to reproduce the problem?

    Geoffrey McGill
    Founder & CEO
  3. #3

    RE: GridPanel sorting null values - bad order

    Thanks, I have found the problem, my Store recordfield has been missing type="String"

            <ext:Store ID="Store1" runat="server">
                <Reader>
                    <ext:ArrayReader>
                        <Fields>
                            <ext:RecordField Name="company" />
                            <ext:RecordField Name="item" Type="String" />
                        </Fields>
                    </ext:ArrayReader>
                </Reader>
            </ext:Store>
  4. #4

    RE: GridPanel sorting null values - bad order

    hmmm. interesting.

    The "String" type is the default value for the field config, but I can confirm that if Type="String" is not specified, the sorting will fail as you noted above.

    We'll have to take another look at this.

    I guess in the mean time, the Type="String" is a simple enough work-around.

    Geoffrey McGill
    Founder & CEO
  5. #5

    One more Question?

    In this Example, if I click on the Item Column then it's Short by ASC.
    in this case, all null and black come first, and I want all Null and blank come last.

    please suggest me what to do?

Similar Threads

  1. [CLOSED] Order GridPanel Groups in an arbitrary order?
    By dmoore in forum 1.x Premium Help
    Replies: 4
    Last Post: Dec 27, 2013, 4:35 AM
  2. [1.2] Postback on null values with autosave
    By hc.dev in forum 1.x Help
    Replies: 4
    Last Post: Jan 04, 2012, 4:52 PM
  3. Replies: 2
    Last Post: Aug 15, 2011, 4:03 PM
  4. datefield and null values
    By PetrSnobelt in forum 1.x Help
    Replies: 0
    Last Post: Jun 06, 2011, 10:51 AM
  5. Replies: 2
    Last Post: Jun 14, 2010, 2:47 PM

Posting Permissions