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.
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Custom sorting for a column

Thread ID:

Created:

Updated:

Platform:

Replies:

21940 Nov 29,2004 07:27 PM UTC Jan 6,2005 08:31 PM UTC Windows Forms 3
loading
Tags: GridControl
Lori S. Pearsall
Asked On November 29, 2004 07:27 PM UTC

I have a GDBG where one of the columns has a custom dropdown that allows the user to specify a start date & time, an end date and time and an indication as to whether the times are estimates or not. Basically this dropdown populates four columns in a table. The cell in the grid displays the results as a string that looks like this (example) : 02/01/2004 14:00:00 - 04/04/2004 15:00:00 When a sort is done, it is basically a string sort so ... 02/01/2004 appears before 03/02/2003 as an example. How can I trap a sort for this particular column so that I can sort on the actual database columns that are of type datetime? Thanks! Lori

Administrator [Syncfusion]
Replied On November 29, 2004 10:05 PM UTC

The GridDataBoundGrid uses the sorting support from the DataView associated with the DataSource. To do a custom sort through the DataView, the object in the column should implement IComparable. When this is done, the DataView will use the IComparable implementation when it tries to sort that column. Here is a forum thread with a sample. http://64.78.18.34/Support/Forums/message.aspx?MessageID=18035 Here is another way to do this that is more involved than just implementing IComparable on a derived object, but it does allow you to sort things with out deriving an object. It does away with teh grid depending upon the DataView.Sort support. This way you can sort columns and not see them move around as you edit entries. You only have to have an IComparer that you can use. You can also use this technique to sort unbound columns. GridDataBoundGridCustomSorting_7069.zip

Lori
Replied On January 6, 2005 08:26 PM UTC

Thanks Clay, I''ll take a look at that sample you provided. One more question - what I''d like to do is, for one column in the grid, sort by a different column that is in the same DataTable that is the DataSource of the grid. Is there an event that I can trap and do this? I know that CellDoubleClicked occurs before the Sort is set.

Administrator [Syncfusion]
Replied On January 6, 2005 08:31 PM UTC

Check out this sample. It shows how you can intercept a sort and sort somethiing else. Syncfusion\Essential Suite\3.0.1.0\Windows\Grid.Windows\Samples\DataBound\DataBoundSortByDisplayMember

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

;