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

Custom sorting in a DataGrid

I have a DataGrid that has a custom TableStyle that contains several custom ColumnStyles. Of these ColumnStyles are a DataGridColumnStyle that hosts a ComboBox control. The underlying value of the column is the numeric ID but the DataGridComboBoxColumnStyle displays a textual description based on a Relation in a DataSet instead. This works wonderfully for displaying and editing the data. However, when you attempt to sort by that column since the underlying value is the numeric ID it sorts based on that value. I was wondering if it would be possible to intercept and implement a sort on my own that could walk the Relation and sort based on the textual description.

2 Replies

AN Andy April 16, 2003 02:04 PM

I saw your post as I was looking for information about how to use the DataGridComboBoxColumStyle to put combos in the datagrid. I have had no luck getting this to work. Do you have any example code for how to use that combobox columstyle in the grid? Thanks in advance, Andy > I have a DataGrid that has a custom TableStyle that contains several custom ColumnStyles. Of these ColumnStyles are a DataGridColumnStyle that hosts a ComboBox control. The underlying value of the column is the numeric ID but the DataGridComboBoxColumnStyle displays a textual description based on a Relation in a DataSet instead. This works wonderfully for displaying and editing the data. > > However, when you attempt to sort by that column since the underlying value is the numeric ID it sorts based on that value. I was wondering if it would be possible to intercept and implement a sort on my own that could walk the Relation and sort based on the textual description.


DO Dominique July 1, 2003 06:09 AM

Hello Justin. Did you get a solution for this problem ? I have the same problem and did not found any solution until now. Thanks for your answer. Dominique > I have a DataGrid that has a custom TableStyle that contains several custom ColumnStyles. Of these ColumnStyles are a DataGridColumnStyle that hosts a ComboBox control. The underlying value of the column is the numeric ID but the DataGridComboBoxColumnStyle displays a textual description based on a Relation in a DataSet instead. This works wonderfully for displaying and editing the data. > > However, when you attempt to sort by that column since the underlying value is the numeric ID it sorts based on that value. I was wondering if it would be possible to intercept and implement a sort on my own that could walk the Relation and sort based on the textual description.

Loader.
Live Chat Icon For mobile
Up arrow icon