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

custom sorting in GridDataBoundGrid

Hi All,

How can i do custom sorting for one column which could be moved by user during work(so, it could be with different col index). I need help exactly with GridDataBoundGrid, cause all examples i found are with another types of grids . I know that need to use IComparer, but i cant find how to link it to GridDataBoundGrid and how to find needed column(i know her name and have instance of GridBoundColumn).
Thanks.

Regards,
Sergey


1 Reply

AD Administrator Syncfusion Team March 28, 2008 05:15 PM UTC

Hi Sergey,

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 theIComparable 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.

Please refer the below sample to implement this.

This sample consist of two GridDataBoundControl.First one is normal and next grid
was design for custom control using IComparer.


Sample

http://websamples.syncfusion.com/samples/Grid.Windows/i42192/main.htm



Please let me know with detailed explanation about your issue if you need further assistance for this.

Best regards,
Johnson




Loader.
Live Chat Icon For mobile
Up arrow icon