Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
310
AfterSortChange
posted

Hi everybody. I am using the event AfterSortChange to handle the sort click on a specific column of my UltraGrid.
Unfortunately I am using also the group by function when I prepare the layout of my grid, here:

private void InitializeGridLayout(object sender, InitializeLayoutEventArgs e)
{
e.Layout.Bands[0].SortedColumns.Add("Status", false, true);
}

So, if a user click on the 'Description' column, when I use the AfterSortChange, if I want to know which column was clicked I use this code:

var columns = e.Band.SortedColumns;

But in this case it returns more than a column and honestly I don't know which one is the one he clicked, because the group by varies on-fly.

Do you suggest a better approach? I also need to know the order type 'asc' or 'desc'.

Parents
  • 310
    posted

    For now I have to keep in consideration all the columns sorted, also the ones in the group header, because my paging system will show, otherwise, part of the grouped columns in the first page and part in another one. I came out with this 'dirty' but functional solution:

            private void AfterSortChange(object sender, BandEventArgs e)
            {
                var columns = e.Band.SortedColumns;
                var sortString = string.Empty;
                if (columns != null && columns.Count > 0)
                {
                    foreach (UltraGridColumn column in columns)
                    {
                        sortString += string.Format(
                            "{0} {1}, ",
                            mapGridKeyToColumnName(column.Key),
                            column.SortIndicator == SortIndicator.Ascending ? "ASC" : "DESC");
                    }

                    sortString = sortString.Remove(sortString.LastIndexOf(","));
                }
            }
Reply Children