We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

How to let grid control can be sort?

How to let grid control can be sort by click column header like grid data control?

3 Replies

CB Clay Burch Syncfusion Team September 22, 2009 05:10 PM UTC

There is no built-in support for sorting a GridControl. Here is a minimal sample that handles the sort by using the virtual QueryCellInfo event to redirect the values so that are in sort order.



SortableGridControl_32ed8b71.zip


LK luo kun September 23, 2009 02:10 AM UTC

I try the example, when some cells are empty cause exception,I changed GridControlSortHelper.cs's line 100 from
Value = (o == null) ? null : o.GetValue(GridStyleInfoStore.CellValueProperty) as IComparable
to
Value = (o == null) ? string.Empty : o.GetValue(GridStyleInfoStore.CellValueProperty) as IComparable
no longer occur exception,
but the results are not sorted correctly, even after clicking on the column header, the value of the cell is not properly be changed.


CB Clay Burch Syncfusion Team September 23, 2009 09:18 AM UTC

Here is the sample back tweaked to handle null entries. The tweaks were in the Compare method to handle empty Value values, and another change in the QueryCellInfo method to make sure empty cells displayed as empty (instead of showing previously cached styles).



SortableGridControl_740015f4.zip

Loader.
Live Chat Icon For mobile
Up arrow icon