ASPxGridView Group Summary Sorting - It sorts the content inside, not the summary outside
Asked Answered
A

2

11

I have done grouping of the grid by giving groupindex to a particular column in aspxgridview.

For example, if I am grouping by means of persons name and the orders details made by that particular person would come in the detailed content when the arrow is clicked to view the content.

When I click on the header fields to sort, it is sorting the data inside the groupContent but it is not used for sorting the data of groupsummary

I am showing all the totals as a part of group summary besides the person's name.

For example if you see in the below link:

https://demos.devexpress.com/ASPxGridViewDemos/Summary/GroupSortBySummary.aspx

If you sort by company name, the content would be sorted, but the summary showing the country and sum has no means to get sorted at outside level.

Please do suggest me options to work out this problem.

Thanks.

Affront answered 6/9, 2012 at 21:0 Comment(1)
Maybe these articles can help you: ASPxGridView - How to sort groups and ASPxGridView - How to sort groups via the GroupSummarySortInfo class.Its
K
1

Here is workaround, based on this example.
The main idea is to create summary item which shows the minimum or maximum value of Country column inside City group and sort City group by this summary values. For this BeforeColumnSortingGrouping event is used to change the sorting behavior.
Here is example:

<dx:ASPxGridView ...
    OnBeforeColumnSortingGrouping="gridCustomers_BeforeColumnSortingGrouping">
private void SortByCountry()
{
    gridCustomers.GroupSummary.Clear();
    gridCustomers.GroupSummarySortInfo.Clear();

    var sortOrder = gridCustomers.DataColumns["Country"].SortOrder;

    SummaryItemType summaryType = SummaryItemType.None;

    switch (sortOrder)
    {
        case ColumnSortOrder.None:
            return;
            break;
        case ColumnSortOrder.Ascending:
            summaryType = SummaryItemType.Min;
            break;
        case ColumnSortOrder.Descending:
            summaryType = SummaryItemType.Max;
            break;
    }

    var groupSummary = new ASPxSummaryItem("Country", summaryType);
    gridCustomers.GroupSummary.Add(groupSummary);

    var sortInfo = new ASPxGroupSummarySortInfo();
    sortInfo.SortOrder = sortOrder;
    sortInfo.SummaryItem = groupSummary;
    sortInfo.GroupColumn = "City";

    gridCustomers.GroupSummarySortInfo.AddRange(sortInfo);
}

protected void Page_Load(object sender, EventArgs e)
{
    SortByCountry();
}

protected void gridCustomers_BeforeColumnSortingGrouping(object sender, ASPxGridViewBeforeColumnGroupingSortingEventArgs e)
{
    SortByCountry();
}
Keshiakesia answered 4/9, 2015 at 11:37 Comment(0)
D
0

When you group by a column devexpress automatically uses that column to sort. Without sorting the data the grouping is not possible. To overcome this issue we have sorted the datasource itself then applied that datasource to the grid.

Donatist answered 18/3, 2015 at 16:11 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.