I would like to handle sorting in a custom way. I know I can use Sorting event for this and set e.Cancel = true. This way I can stop grid from performing sorting on its own.
The problem is that I would still like to have a sorting indicator in the header (near label). I can accomplish that by adding following line to the Sorting event handler:
e.FieldLayout.SortedFields.Add(e.SortDescription);
but after that the default sorting mechanism executes despite setting e.Cancel = true. What's your ideas on that?
Hello,
Thank you for your post. I have been looking into it and I created a sample project for you with the functionality you want. Basically I handled the Sorting event, canceled it and added a SortDescription. As for the Filtering, I added a button and in its Click event I filtered the Records. Please let me know if this helps you or you need further assistance on this matter.
Looking forward for your reply.
Hi Stefan,
Thanks for the reply.
The sample project you created shows exactly the issue I'm having.
Even though you set e.Cancel = true for the Sorting event, after adding SortDescription you can see that grid gets sorted the first time you click any label. This means that adding SortDescription triggers sorting somehow and setting e.Cancel = true does not help here.
For filtering I'm using RecordFilterChanging event in analogic way as for sorting and I'm observing the same behavior: modifying RecordFilters collection on FieldLayout also triggers default filtering even though I set e.Cancel = true.