Skip to main content
A newer version of this page is available. .

GridGroupSummarySortInfo Class

Represents an element in the GridGroupSummarySortInfoCollection.

Namespace: DevExpress.Xpf.Grid

Assembly: DevExpress.Xpf.Grid.v19.2.dll

Declaration

public class GridGroupSummarySortInfo :
    IDetailElement<GridGroupSummarySortInfo>

Remarks

Group rows displayed within the grid can be sorted by their summary values (if any). Group rows are sorted by summary values based upon the information provided by GridGroupSummarySortInfo objects. The properties introduced by these objects specify the sort order, summary item used to calculate summary values for groups of rows, etc.

To sort group rows by summary values, you should create a new GridGroupSummarySortInfo object with the specified settings (group summary item, grouping column and sort order) and add it to the GridControl.GroupSummarySortInfo collection. To cancel sorting the group rows by summary values, remove the corresponding GridGroupSummarySortInfo object from the collection.

To learn more, see Sorting Group Rows by Summary Values.

Example

This example shows how to sort group row by summary values.

using System;
using System.Collections.Generic;
using System.Windows;
using System.Windows.Documents;
using DevExpress.Xpf.Grid;

namespace DXSample_SortGroupsBySummary {
    public partial class Window1 : Window {
        public Window1() {
            InitializeComponent();
            grid.ItemsSource = new AccountList().GetData();
            SortGroupsBySummary(view.GroupedColumns[0]);
        }
        private void SortGroupsBySummary(GridColumn column) {
            GridGroupSummarySortInfo sortInfo = new GridGroupSummarySortInfo(grid.GroupSummary[0],
                column.FieldName, System.ComponentModel.ListSortDirection.Ascending);
            grid.GroupSummarySortInfo.Add(sortInfo);
        }
    }
    public class AccountList {
        public List<Account> GetData() {
            return CreateAccounts();
        }
        private List<Account> CreateAccounts() {
            List<Account> list = new List<Account>();
            list.Add(new Account() { UserName = "Nick White", 
                RegistrationDate = DateTime.Today, Age = 57 });
            list.Add(new Account() { UserName = "Jack Rodman",
                RegistrationDate = new DateTime(2009, 5, 10), Age = 24 });
            list.Add(new Account() { UserName = "Sandra Sherry",
                RegistrationDate = new DateTime(2009, 5, 10), Age = 35 });
            list.Add(new Account() { UserName = "Sabrina Vilk",
                RegistrationDate = DateTime.Today, Age = 19 });
            list.Add(new Account() { UserName = "Mike Pearson",
                RegistrationDate = new DateTime(2008, 10, 18), Age = 42 });
            return list;
        }
    }
    public class Account {
        public string UserName { get; set; }
        public DateTime RegistrationDate { get; set; }
        public int Age { get; set; }
    }
}

Inheritance

Object
GridGroupSummarySortInfo
See Also