I have Gridview that is abound to a collection of object “Benefit”, which has an Amount (decimal) that I would like to group on it is value. I have ranges with a text value that returns the corresponding range for that amount
Less than 100
100 – 250
250 – 500
Greater than 500
When I apply a group descriptor, the grouping occurs on these text vales, but it is sorted alphabetically. How can control the sorting of the group itself? I can convert that Range property to return integer value, but I still want to display the group text as above. I tried the Generic Group Descriptor <TElement, TKey, TSortKey> but didn’t help.
How can resolve this?
Cheers
5 Answers, 1 is accepted
Have you checked this forum thread? Why using the Generic Group Descriptor <TElement, TKey, TSortKey> didn’t help ?
Didie
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
Thank you for the reply. I actually have seen that thread, and I tried to follow it. However, Group Descriptor <TElement, TKey, TSortKey> resulted in groups of 1 element only, and the desiplayed name in the group panel was the Class long name (with name space).
Below is the code, I have property ApprovalRange which is string for the group name, and another property ApprovalSortRange which is an integer that I want to sort the group on (1 to 4). The colu,mn itself is amount which is decimal.
var disc = new GroupDescriptor<BenefitApprovalModelItem, BenefitApprovalModelItem, int>
{
GroupingExpression = item => item,
GroupSortingExpression = grouping => grouping.Key.ApprovalRangeSort,
DisplayContent = "ApprovalRange",
SortDirection = ListSortDirection.Ascending
};
You can override the ToString() method for the BenefitApprovalModelItem item to return the value that you want to appear in the group row.
Greetings,Didie
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
That won’t help since the grouping itself is not right. This method resulted in all groups having 1 row only each!!! Is there anything wrong with the way I using that descriptor?
Indeed, it is like so. This is the expected behaviour though as you group by the entire item: GroupingExpression = item => item. You have to group on a property of the BenefitApprovalModelItem and set the type of the property as second type when the GroupDescriptor is defined.
Didie
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>