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

GDBG sort by two columns

Hello,
I have gdbg bounded to a dataview. Dataview is sorted by specific_column. When user click on column header data is sorted by user_clicked_column. I need to sort data after user click by two columns - first by specific_column and then by user_clicked_column. Is there a way to do this?

Thanks!

3 Replies

HA haneefm Syncfusion Team October 31, 2007 02:36 PM UTC

Hi Valery,

The GridDataBoundGrid uses the sorting support from the DataView associated with the underlying datasource of the grid. If you want to do a multiple sort through the DataView in a Grid, you need to handle the CellClick event of the grid and set the DataView.Sort property on the datasource to sort by multiple columns. Below are the codes that shows this task.

// Get the DefaultViewManager of a underlying datasource.

DataView myDataView = this.Grid.DataSource as DataView;

// By default, the first column sorted ascending.

myDataView.Sort = "State, ZipCode DESC";
e.Handled = true;

GridDataBoundGrid has support for Multicolumn sorting, refer this KB article for more details.
http://www.syncfusion.com/support/kb/grid/Default.aspx?ToDo=view&questId=110



Best regards,
Haneef


VA Valerij November 2, 2007 07:07 AM UTC

But how in this case can I display sort icon in column headers?


JJ Jisha Joy Syncfusion Team November 5, 2007 01:22 PM UTC

Hi Valery,

Thank you for your update.

The sample in the mentioned KnowledgeBase article uses GridMultiColSortHelper class to perform the multicolumn sorting. Sort direction of each column is stored in the Tag property of the grid column header. Sort icon can be seen when we click on the column header for sorting.

Here is the screen shot of that sample that shows sort icons:
shot.zip

Please let me know if you have any questions.

Thanks,
Jisha


Loader.
Live Chat Icon For mobile
Up arrow icon