Hi,
I am looking for a way to turn off the display of the Sort Indicator on a sorted column while retaining the ability for the user to sort the column.
I have searched the forum and found a similar question - the suggested fix was to use a CreationFilter on the grid to cancel the creation of the SortIndicatorUIElement.
This does stop the indicator being displayed - however my problem is that the space is still made for the indicator anyway. How do I prevent this?
This results in wrapping of the header text unless I resize the column to fit the updated column header.
I have very strict (and unique!) requirements to save as much space as possible to resizing the column is not an option. I need to hide the indicator AND stop the grid reserving space for it also.
I have tried numerous workarounds involving resetting the columns SortIndicator property to None. This does the trick when sorting Ascending however when sorting Descending it reverts the sort to Ascending :-(
Any suggestions are most welcome.
Thanks!
I'm not sure I understand your question.
HeaderClickAction.ExternalSortSingle means that the grid will display a Sort Indicator in the column header, but the grid will not actually sort the data.
So if you are trying to remove sorting from the grid, you should be turning off sorting entirely by setting HeaderClickAction to None or Select.
If you want to sort the data, then the best thing to do is to sort the data in your data source before you bind it to the grid. Or, if you are changing the sort order after the grid is bound, you need to tell the grid to refresh itself after the sort is complete.
To refresh the grid, call:
grid.Rows.Refresh(ReloadData);
I would like to manually sort the Ultragrid.
I'd like to remove the sorting from the Header Column. I am using the following to remove sorting
e.Layout.Override.HeaderClickAction =
HeaderClickAction.ExternalSortSingle;
However, even if I call refreshSort() before binding the table to the grid,
I am unable to sort the grid.
Is there something that I am missing ?
Hm. I think you could try handling the BeforeSortChange event and then set the SortIndicator on every column.
Is there a way to always force the sort indicator to be ON for every column??
I can set all the columns to Ascending on the Initialize_Layout. The problem is as I choose 1 column to sort the column to the left of my sorted column drops the sort indicator.
Hi Mike
Thank you! Your better (and simpler) creation filter alone solves the problem. I do not even need the MouseUp code to artifically do the sorting. Setting HeaderClickAction on the grid to SortSingle and using your creation filter to hide the indicator does the job perfectly. I think my creation filter was trying to this the wrong way and failing to remove the space occupied by the sort indicator.
Thanks again for all the help!