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. (Last updated on : Nov 16th 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to let grid control can be sort?

Thread ID:

Created:

Updated:

Platform:

Replies:

90205 Sep 22,2009 05:15 AM UTC Sep 23,2009 09:18 AM UTC WPF 3
loading
Tags: GridControl
luo kun
Asked On September 22, 2009 05:15 AM UTC

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

Clay Burch [Syncfusion]
Replied On 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

luo kun
Replied On 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.

Clay Burch [Syncfusion]
Replied On 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

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;