I'm looking for a way to get the GridViewComboBoxColumn to sort on the DisplayMemberPath, but I do not want to code this for every single grid with custom sorting or every single GridViewComboBoxColumn I add to our application. There are a number of developers on this project and undoubtedly one will forget to do it, and this is not really maintainable either.
Ideally I could have my own SortableGridViewComboBoxColumn I could use that inherited from the GridViewComboBoxColumn but I have not had much luck going down this road so far. Is there any advice you can give or samples I can look at? I've been through almost everything on this forum already.
8 Answers, 1 is accepted
What happens if I add a new object to the collection? Now I have to loop through the entire collection and set the "SortID" property for every combo box column in the grid. Not elegant.
I am looking for a way to get the control to sort by DisplayMemberPath so I don't need to create many many seperate properties for the grids in our application.
Indeed additional setting of the SortMemberPath will be needed. In order to avoid this, you could handle the Sorting event of the RadGridView and apply your custom sorting which sorts based on the DisplayMemberPath. You can check the CustomSorting WPF Demo and our online documentation for an example.Greetings,
the Telerik team
Is there no way to inherit from the GridViewComboBoxColumn and write some generic code to sort? That way we simply use this new column and the application will behave as all users would expect it to behave.
Unfortunately this is what we can suggest regarding Sorting of this column. Inheriting it will not help as the sorting logic is in the Data Engine, it is not in the column.Kind regards,
the Telerik team
No, I never got it working. I did try using a custom column but that had its own challenges. What I typically do now is use a regular data column and change the cell edit template to a combo box.
I found out a solution, maybe it could be simplier, but for me it is good enough.
First you have to set ".IsCustomSortingEnabled = True" on the GridViewComboBoxColumn.
Then in the sorting handler:
Maybe you will find an eleganter solution.