[FIXED] [#289] [2.x] default Sort Direction doesn't work?

  1. #1

    [FIXED] [#289] [2.x] default Sort Direction doesn't work?

    Hi, in my ModelField config, I stated that the SortDir="DESC". But it doesn't seem to sort descendingly on first click. Also, if I supplied a DefaultValue config to the ModelField (e.g., DefaultValue="Test'), javascript errors occur.

    <script runat="server">
        Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
            Dim list As New List(Of Object)
            For index = 1 To 25
                list.Add(New With {.Id = index, .Name = "Name " + index.ToString(), .Description = "Description " + index.ToString(), .Grouping = "Group 1"})
            Next
            For index = 26 To 50
                list.Add(New With {.Id = index, .Name = "Name " + index.ToString(), .Description = "Description " + index.ToString(), .Grouping = "Group 2"})
            Next
            
            Me.Store1.DataSource = list
            Me.Store1.DataBind()
        End Sub
    </script>
    
    <html>
    <head id="Head1" runat="server">
    </head>
    <body>
        <form runat="server">
        <ext:ResourceManager ID="ResourceManager1" runat="server" />
        <ext:Button ID="Button1" runat="server" Text="Show Window" Icon="Application">
            <Listeners>
                <Click Handler="#{Window1}.show(this);" />
            </Listeners>
        </ext:Button>
        <ext:Window ID="Window1" runat="server" Hidden="false" Maximizable="true" Width="500"
            Height="500">
            <LayoutConfig>
                <ext:FitLayoutConfig>
                </ext:FitLayoutConfig>
            </LayoutConfig>
            <Items>
                <ext:GridPanel runat="server" Title="Restaurants" Frame="true">
                    <Store>
                        <ext:Store runat="server" ID="Store1">
                            <Model>
                                <ext:Model runat="server">
                                    <Fields>
                                        <ext:ModelField Name="Id" SortDir="ASC"/>
                                        <ext:ModelField Name="Name" SortDir="DESC" />
                                        <ext:ModelField Name="description" />
                                        <ext:ModelField Name="rating" Type="Int" />
                                    </Fields>
                                </ext:Model>
                            </Model>
                        </ext:Store>
                    </Store>
                    <ColumnModel runat="server">
                        <Columns>
                            <ext:Column runat="server" Text="Id" Flex="1" DataIndex="Id" />
                            <ext:Column runat="server" Text="Name" Flex="1" DataIndex="Name" />
                        </Columns>
                    </ColumnModel>
                </ext:GridPanel>
            </Items>
        </ext:Window>
        </form>
    </body>
    </html>
    Last edited by fabricio.murta; Apr 27, 2016 at 1:57 AM.
  2. #2
    Hello!

    You should use the Store's Sorters property:

    <%@ Page Language="VB" %>
    
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" 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 Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
            Dim list As New List(Of Object)
            For index = 1 To 25
                list.Add(New With {.Id = index, .Name = "Name " + index.ToString(), .Description = "Description " + index.ToString(), .Grouping = "Group 1", .Rating = index / 5})
            Next
            For index = 26 To 50
                list.Add(New With {.Id = index, .Name = "Name " + index.ToString(), .Description = "Description " + index.ToString(), .Grouping = "Group 2", .Rating = index / 5})
            Next
             
            Me.Store1.DataSource = list
            Me.Store1.DataBind()
        End Sub
    </script>
     
    <html>
    <head id="Head1" runat="server">
    </head>
    <body>
        <form runat="server">
        <ext:ResourceManager ID="ResourceManager1" runat="server" SourceFormatting="True" ScriptMode="Debug" />
        <ext:Button ID="Button1" runat="server" Text="Show Window" Icon="Application">
            <Listeners>
                <Click Handler="#{Window1}.show(this);" />
            </Listeners>
        </ext:Button>
        <ext:Window ID="Window1" runat="server" Hidden="false" Maximizable="true" Width="500"
            Height="500">
            <LayoutConfig>
                <ext:FitLayoutConfig>
                </ext:FitLayoutConfig>
            </LayoutConfig>
            <Items>
                <ext:GridPanel runat="server" Title="Restaurants" Frame="true" SortableColumns="True">
                    <Store>
                        <ext:Store runat="server" ID="Store1" RemoteSort="False">
                            <Model>
                                <ext:Model runat="server">
                                    <Fields>
                                        <ext:ModelField Name="Id" Type="Int" />
                                        <ext:ModelField Name="Name" />
                                        <ext:ModelField Name="Description" />
                                        <ext:ModelField Name="Rating" Type="Int" />
                                    </Fields>
                                </ext:Model>
                            </Model>
                            <Sorters>
                                <ext:DataSorter Property="Rating" Direction="ASC"></ext:DataSorter>
                                <ext:DataSorter Property="Name" Direction="DESC"></ext:DataSorter>
                            </Sorters>
                        </ext:Store>
                    </Store>
                    <ColumnModel runat="server">
                        <Columns>
                            <ext:Column runat="server" Text="Id" Flex="1" DataIndex="Id" />
                            <ext:Column runat="server" Text="Name" Flex="1" DataIndex="Name" />
                            <ext:Column runat="server" Text="Rating" Flex="1" DataIndex="Rating" />
                        </Columns>
                    </ColumnModel>
                </ext:GridPanel>
            </Items>
        </ext:Window>
        </form>
    </body>
    </html>
  3. #3
    Hi everybody,

    Yes, a ModelField's SortDir appears to be not working. I have asked Sencha about that.
    http://www.sencha.com/forum/showthre...l=1#post976876

    I would expect it should set up a default sort direction for a Store's sorter, i.e. this combination
    <ext:ModelField Name="Name" SortDir="DESC" />
    <ext:DataSorter Property="Name" />
    should sort the Name ModelField in the descending order.
  4. #4
    Also, if I supplied a DefaultValue config to the ModelField (e.g., DefaultValue="Test'), javascript errors occur.
    You have to wrap the string value by single quotes inside double quotes (sinle quotes mean that it is string, not bool (like true) or something else)
    DefaultValue="'Test'"
    Vladimir Shcheglov
    Sr. Developer
  5. #5
    Thanks Daniil and Vladimir, I can see a bug report created. Baidaly, that wasn't my intention, thanks too though.
  6. #6
    Created an Issue to track this defect.
    https://github.com/extnet/Ext.NET/issues/289
  7. #7
    Hello! Sencha claims this issue as fixed for some time now! We are following-up to their position and marking this as fixed here. If this bug still bugs someone, just let us know! Notice we expect newer versions of Ext.NET not to have this bug (3.3 or 4.0). Legacy versions may still have it as the fixes to many many issues went just to the newer versions as the software evolved.
    Fabrício Murta
    Developer & Support Expert

Similar Threads

  1. Replies: 2
    Last Post: Mar 20, 2015, 1:45 PM
  2. Replies: 5
    Last Post: Jul 31, 2013, 1:57 PM
  3. Replies: 3
    Last Post: Jun 13, 2011, 5:17 PM
  4. Sort with Conditional sort direction in JS- help!
    By Tbaseflug in forum 1.x Help
    Replies: 2
    Last Post: May 05, 2009, 1:11 PM
  5. Replies: 2
    Last Post: Mar 26, 2008, 10:41 AM

Tags for this Thread

Posting Permissions