I am using radgridview in my wpf application.When I drag and drop a column to the group panel, the sorting of groups is not done numerically as it is a string field.
I want the grouped data to be sorted numerically.
Any help would be really appreciated.
1 Answer, 1 is accepted
0
Dilyan Traykov
Telerik team
answered on 14 Mar 2018, 01:25 PM
Hello harsha,
There are two approaches you can try in such a scenario:
1) Handle the Grouping and replace the default ColumnGroupDescriptor with a generic one as demonstrated by my colleague in this forum thread. Here's an example:
var columnGroup = e.GroupDescriptor as ColumnGroupDescriptor;
if (columnGroup != null && columnGroup.Column.UniqueName == "Id")
{
// cancel the default grouping
e.Cancel = true;
// define a generic GroupDescriptor
var descriptor = new GroupDescriptor<Club, string, int>
{
GroupingExpression = o => o.Id,
GroupSortingExpression = group => int.Parse(group.Key),
SortDirection = e.GroupDescriptor.SortDirection,
DisplayContent = "Id"
};
// add the new descriptor
clubsGrid.GroupDescriptors.Add(descriptor);
}
}
}
2) Introduce a new calculated property in your business objects which holds the numeric representation of the string value and bind the column to that property.
Please let me know if any of these methods works for you. I look forward to your reply.
Regards,
Dilyan Traykov
Progress Telerik
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.