Default sorting not needed when grouped

1 Answer 74 Views
GridView
Shubham
Top achievements
Rank 3
Iron
Iron
Iron
Shubham asked on 27 Jul 2023, 08:01 AM

Hi ,
When we group by any column by default sorting is applied on that column. I don't need that sorting.

In Below Image You can see I just grouped with 3 columns namely "Internal Id" , "Description" and "IMS Description" and sorting is applied on them automatically I don't want that default sorting behavior.

I just wanted if user want sorting he can sort according to his will but not because of grouping.

Regards,
Shubham Jain

1 Answer, 1 is accepted

Sort by
0
Dinko | Tech Support Engineer
Telerik team
answered on 31 Jul 2023, 03:54 PM

Hi Shubham,

Thank you for the provided details.

If I have correctly understood your scenario, you want to remove the applied sort when the user grouped the control for the first time. In this case, you can subscribe to the GroupByChanging event of the control. In the event handler, you can clear the SortDescriptors collection if the control is grouped for the first time.

this.radGridView1.GroupByChanging += RadGridView1_GroupByChanging;

private void RadGridView1_GroupByChanging(object sender, GridViewCollectionChangingEventArgs e)
{
    if(this.radGridView1.GroupDescriptors.Count>0)
    {
        this.radGridView1.SortDescriptors.Clear();
    }
}

You can extend the IF clause in the event handler to match your scenario. I hope that this approach will work for you.

Regards,
Dinko | Tech Support Engineer
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Shubham
Top achievements
Rank 3
Iron
Iron
Iron
commented on 01 Aug 2023, 05:46 AM

Hi Dinko,

It is not working form me it is same no changes,
When I am debugging this i find that count of sortdesciptor is already zero radGridView.SortDescriptor.Count= 0.

 

Thanks,
Shubham Jain

Dinko | Tech Support Engineer
Telerik team
commented on 01 Aug 2023, 10:44 AM

In this case, I will need more information on how the control is sorted. Can you create a video of the described behavior and the steps which leads to the visual look shown in the image? Basically, if the SorceDescriptors are empty, then the control does not have any sort optioned applied. Which leads me to think I am missing something here. It will be best if you can isolate this behavior in a standalone project so that I can debug it and try to suggest a suitable solution here.

I am looking forward to your reply.

Tags
GridView
Asked by
Shubham
Top achievements
Rank 3
Iron
Iron
Iron
Answers by
Dinko | Tech Support Engineer
Telerik team
Share this question
or