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.
I have been looking into the project I sent you before and I modified, so now the Sorting and Filtering is made directly to the DataSource and a sort indicator is shown if there is sorting. Also I can say that the Sorting and Filtering events of the XamDataGrid are fired if you sort or filter using the UI of the control, if do this by code, no matter if you modify the RecordFilters or SortedFields collection the events are not fired. In my sample I handled both events and canceled them, but it is not necessarily if you don’t use the UI for sorting and filtering. Please let me know if this helps you or you need further assistance on this matter.
Hello Shahin,
Thank you for your feedback. I am glad that you resolved your issue and I believe that other community members may benefit from this as well.
Thanks again.
Thanks for the quick answer Stefan
This link had the answer i was looking for
http://ko.infragistics.com/community/forums/t/29668.aspx
Thank you for your post. I have been looking into it and I can suggest you see these two forum threads:
and
http://ko.infragistics.com/community/forums/t/36824.aspx
Hi
I am facing a similar issue. I am sorting the grid in the code, and binding the result to the grid. I have looked at your samples, and figured how to prevent the grid from executing the sort and also to show the sort indicator without adding sort descriptions to the grid in code.
But i am not able to figure out how to change the Sort Indicator to correspond to the Sort Direction. Right now when i make the Sort Indicator visible it always shows the Sort indicator as Descending. I was also relying on the Sort Status value changing in the xaml to change the color of the column header when it is sorted on.
I want to show the right Sort Indicator based on the actual sort direction. I wont be able to add the Sort Description to the grid since i dont want the grid to sort on the clicked field. Back end code sorts on a different field when user clicks to sort the field. So adding Sort descriptions and letting the grid do the sorting will mess up the Sort order.
Any help is appreciated
Thanks
SR