[CLOSED] Sorting group in grouping grid panel

  1. #1

    [CLOSED] Sorting group in grouping grid panel

    Hi.
    I need to sort group in grouping grid panel.
    For example:
    <%@ Page Language="C#" %>
    <%@ Import Namespace="System.Collections.Generic" %>
    
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    
    <!DOCTYPE html>
    
    <script runat="server">
        protected void Page_Load(object sender, EventArgs e)
         {
             this.Store1.DataSource = new List<Project> 
             { 
                new Project(100, "Ext Forms: Field Anchoring", 112, "Integrate 2.0 Forms with 2.0 Layouts", 6, 150, 0, new DateTime(2007, 06, 24)),
                new Project(100, "Ext Forms: Field Anchoring", 113, "Implement AnchorLayout", 4, 150, 0, new DateTime(2007, 06, 25)),
                new Project(100, "Ext Forms: Field Anchoring", 114, "Add support for multiple types of anchors", 4, 150, 0, new DateTime(2007, 06, 27)),
                new Project(100, "Ext Forms: Field Anchoring", 115, "Testing and debugging", 8, 0, 0, new DateTime(2007, 06, 29)),
                new Project(101, "Ext Grid: Single-level Grouping", 101, "Add required rendering \"hooks\" to GridView", 6, 100, 0, new DateTime(2007, 07, 01)),
                new Project(101, "Ext Grid: Single-level Grouping", 102, "Extend GridView and override rendering functions", 6, 100, 0, new DateTime(2007, 07, 03)),
                new Project(101, "Ext Grid: Single-level Grouping", 103, "Extend Store with grouping functionality", 4, 100, 0, new DateTime(2007, 07, 04)),
                new Project(101, "Ext Grid: Single-level Grouping", 121, "Default CSS Styling", 2, 100, 0, new DateTime(2007, 07, 05)),
                new Project(101, "Ext Grid: Single-level Grouping", 104, "Testing and debugging", 6, 100, 0, new DateTime(2007, 07, 06)),
                new Project(102, "Ext Grid: Summary Rows", 105, "Ext Grid plugin integration", 4, 125, 0, new DateTime(2007, 07, 01)),
                new Project(102, "Ext Grid: Summary Rows", 106, "Summary creation during rendering phase", 4, 125, 0, new DateTime(2007, 07, 02)),
                new Project(102, "Ext Grid: Summary Rows", 107, "Dynamic summary updates in editor grids", 6, 125, 0, new DateTime(2007, 07, 05)),
                new Project(102, "Ext Grid: Summary Rows", 108, "Remote summary integration", 4, 125, 0, new DateTime(2007, 07, 05)),
                new Project(102, "Ext Grid: Summary Rows", 109, "Summary renderers and calculators", 4, 125, 0, new DateTime(2007, 07, 06)),
                new Project(102, "Ext Grid: Summary Rows", 110, "Integrate summaries with GroupingView", 10, 125, 0, new DateTime(2007, 07, 11)),
                new Project(102, "Ext Grid: Summary Rows", 111, "Testing and debugging", 8, 125, 0, new DateTime(2007, 07, 15))
             };
    
            this.Store1.DataBind();
        }
    
        public class Project
        {
            public Project(int projectId, string name, int taskId, string description, int estimate, double rate, double cost, DateTime due)
            {
                this.ProjectID = projectId;
                this.Name = name;
                this.TaskID = taskId;
                this.Description = description;
                this.Estimate = estimate;
                this.Rate = rate;
                this.Due = due;
            }
    
            public int ProjectID { get; set; }
            public string Name { get;set; }
            public int TaskID { get; set; }
            public string Description { get;set; }
            public int Estimate { get;set; }
            public double Rate { get; set; }
            public double Cost { get; set; }
            public DateTime Due { get; set; }
        }
    </script>
    
    <html>
    <head id="Head1" runat="server">
        <title>GroupingSummary Plugin - Ext.NET Examples</title>
        
    </head>
    <body>
        <form id="Form1" runat="server">
            <h1>Group Summary Plugin</h1>
    
            <ext:ResourceManager ID="ResourceManager1" runat="server"/>
            
            <ext:Store ID="Store1" runat="server" GroupField="Name">
                <Sorters>
                    <ext:DataSorter Property="Due" Direction="DESC" />
                </Sorters>
                <Model>
                    <ext:Model ID="Model1" runat="server" IDProperty="TaskID">
                        <Fields>
                            <ext:ModelField Name="ProjectID" />
                            <ext:ModelField Name="Name" />
                            <ext:ModelField Name="TaskID" />
                            <ext:ModelField Name="Description" />
                            <ext:ModelField Name="Estimate" Type="Int" />
                            <ext:ModelField Name="Rate" Type="Float" />
                            <ext:ModelField Name="Cost" Type="Float" />
                            <ext:ModelField Name="Due" Type="Date" />
                        </Fields>
                    </ext:Model>
                </Model>
            </ext:Store>
            
            <ext:GridPanel 
                ID="GridPanel1" 
                runat="server" 
                Frame="true"
                StoreID="Store1"
                Title="Sponsored Projects" 
                Collapsible="true"
                AnimCollapse="false"
                Icon="ApplicationViewColumns"
                Width="800"
                Height="600">
                <ColumnModel ID="ColumnModel1" runat="server">
                    <Columns>
                        <ext:SummaryColumn ID="SummaryColumn1"                        
                            runat="server"
                            TdCls="task"
                            Text="Task"                       
                            Sortable="true"
                            DataIndex="Description"
                            Hideable="false"
                            SummaryType="Count"
                            Flex="1">
                            <SummaryRenderer Handler="return ((value === 0 || value > 1) ? '(' + value +' Tasks)' : '(1 Task)');" />                            
                        </ext:SummaryColumn>
                         
                        <ext:Column ID="Column1" runat="server" Text="Project" DataIndex="Name" Width="20" />
                         
                        <ext:SummaryColumn ID="SummaryColumn2"
                            runat="server"
                            Width="85"
                            Text="Due Date"
                            Sortable="true"
                            DataIndex="Due"
                            SummaryType="Max">
                            <Renderer Format="Date" FormatArgs="'d.m.Y'" />
                            <SummaryRenderer Fn="Ext.util.Format.dateRenderer('d.m.Y')" />
                        </ext:SummaryColumn>
     
                        <ext:SummaryColumn ID="SummaryColumn3"
                            runat="server"  
                            Width="75"
                            Text="Estimate"
                            Sortable="true"
                            DataIndex="Estimate"
                            SummaryType="Sum">
                        </ext:SummaryColumn>
                         
                        <ext:SummaryColumn ID="SummaryColumn4"
                            runat="server"
                            Width="75"
                            Text="Rate"
                            Sortable="true"
                            DataIndex="Rate"
                            SummaryType="Average">
                        </ext:SummaryColumn>
                         
                        <ext:SummaryColumn
                            runat="server"
                            Width="75"
                            ID="Cost"
                            Text="Cost"
                            Sortable="false"
                            Groupable="false"
                            DataIndex="Cost">
                        </ext:SummaryColumn>
                    </Columns>                
                </ColumnModel>
                <View>
                    <ext:GridView ID="GridView1" runat="server" StripeRows="true" MarkDirty="false" />
                </View>
                <Features>               
                    <ext:GroupingSummary ID="GroupingSummary1" runat="server" GroupHeaderTplString="{name}" HideGroupedHeader="true" EnableGroupingMenu="false" StartCollapsed="true" >                   
                    </ext:GroupingSummary>
                </Features>     
            </ext:GridPanel>
        </form>
      </body>
    </html>
    Grid rows has sorting by "Due" but this sorting is in the each group. And the groups themselves are not sorted in reverse order.
    How can i do sorting group ?
    Last edited by Daniil; Dec 10, 2012 at 4:41 AM. Reason: [CLOSED]
  2. #2
    Hi @ginsar,

    Well, the groups itself can be sorted only by a field which these groups are grouped by.

    There is no built-in functionality to sort groups by other fields. But you could try to implement it.
  3. #3
    In my example I made a sort by field "Due".
    In browser rows have sort direction desc (in each group, as I wanted), but groups themselves have sort direction asc (as I did not want).
    I want that groups and rows have sort direction desc.
    How can I set sort direction desc by field "Due" on groups.
  4. #4
    I don't think there is a good way to achieve it with client grouping.

    But you can organize remote grouping.

    1. Set up RemoteGroup="true" for the Store.

    2. And group the data as you need on a server.

    this.Store1.DataSource = new List<Project> 
        { 
            new Project(102, "Ext Grid: Summary Rows", 111, "Testing and debugging", 8, 125, 0, new DateTime(2007, 07, 15)),
            new Project(102, "Ext Grid: Summary Rows", 110, "Integrate summaries with GroupingView", 10, 125, 0, new DateTime(2007, 07, 11)),
            new Project(102, "Ext Grid: Summary Rows", 109, "Summary renderers and calculators", 4, 125, 0, new DateTime(2007, 07, 06)),
            new Project(102, "Ext Grid: Summary Rows", 108, "Remote summary integration", 4, 125, 0, new DateTime(2007, 07, 05)),
            new Project(102, "Ext Grid: Summary Rows", 107, "Dynamic summary updates in editor grids", 6, 125, 0, new DateTime(2007, 07, 05)),
            new Project(102, "Ext Grid: Summary Rows", 106, "Summary creation during rendering phase", 4, 125, 0, new DateTime(2007, 07, 02)),
            new Project(102, "Ext Grid: Summary Rows", 105, "Ext Grid plugin integration", 4, 125, 0, new DateTime(2007, 07, 01)),
            new Project(101, "Ext Grid: Single-level Grouping", 104, "Testing and debugging", 6, 100, 0, new DateTime(2007, 07, 06)),
            new Project(101, "Ext Grid: Single-level Grouping", 121, "Default CSS Styling", 2, 100, 0, new DateTime(2007, 07, 05)),
            new Project(101, "Ext Grid: Single-level Grouping", 103, "Extend Store with grouping functionality", 4, 100, 0, new DateTime(2007, 07, 04)),
            new Project(101, "Ext Grid: Single-level Grouping", 102, "Extend GridView and override rendering functions", 6, 100, 0, new DateTime(2007, 07, 03)),
            new Project(101, "Ext Grid: Single-level Grouping", 101, "Add required rendering \"hooks\" to GridView", 6, 100, 0, new DateTime(2007, 07, 01)),
            new Project(100, "Ext Forms: Field Anchoring", 115, "Testing and debugging", 8, 0, 0, new DateTime(2007, 06, 29)),
            new Project(100, "Ext Forms: Field Anchoring", 114, "Add support for multiple types of anchors", 4, 150, 0, new DateTime(2007, 06, 27)),
            new Project(100, "Ext Forms: Field Anchoring", 113, "Implement AnchorLayout", 4, 150, 0, new DateTime(2007, 06, 25)),
            new Project(100, "Ext Forms: Field Anchoring", 112, "Integrate 2.0 Forms with 2.0 Layouts", 6, 150, 0, new DateTime(2007, 06, 24)),
        };
  5. #5
    Thank you Daniel.
    This is what I needed.

Similar Threads

  1. [OPEN] [#26] Grid panel grouping and sorting from code-behind
    By Manni in forum 2.x Legacy Premium Help
    Replies: 9
    Last Post: Dec 12, 2012, 11:19 PM
  2. [CLOSED] Use Grid Grouping without sorting by the groupField ?
    By ndotis in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Sep 08, 2011, 8:17 PM
  3. [CLOSED] Dynamic Grid, Sorting and Grouping Issue
    By SymSure in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Mar 16, 2010, 2:06 PM
  4. [CLOSED] Grouping doesn't group entire grid data...just current page.
    By rthiney in forum 1.x Legacy Premium Help
    Replies: 5
    Last Post: Mar 05, 2010, 3:34 PM

Posting Permissions