Hi,
my problem is that I have to visualize some values as images. So I have a datatable including columns of integers (0/1). In the UltraGrid I have referenced ValueLists for these columns. So after data was loaded different images will be shown in this columns to visualize an order or payment status for example. That is working fine. But if I want to sort the grid by that columns nothing happens when clicking at the column header. For all other columns the sorting is working correct. Maybe the sorting will not work if columns are referencing value lists?
What I want to know is how can I sort the grid by columns which has references to value lists or a how can I implement a single header click event to sort the grid programmatically. Can anyone help me?
Kind regards,
Ralf
Hi Ralf,
The column is probably sorting by the image rather than by the value. Since all images are essentialy the same in terms of sort order, nothing happens.
You should be able to get this to work the way you want, but how you do it depends on how you are setting up the list.
The first thing I would suggest is that you try playing around with the DisplayStyle property on the ValueList and see if a setting there will help.
If that doesn't work, what you should do is write an IComparer class and assign it to the SortComparer property of the grid column. This will allow you to sort any way you want.
Hi Mike,
thank you for reply.
I thought the grid will be sorted by the data value and not by the display value. I will test your suggestions.
... 5 minutes later.
Your suggestion about the ValueList DisplayStyle is the right solution for my problem. I have set the style to DisplayStyle.Picture and now I can sort the column as I want.
Ralf Friedrich said:I thought the grid will be sorted by the data value and not by the display value.
FYI, the grid sorts by the displayed text, not the underlying value. This makes sense when you think about it. If you have a column where you are using a ValueList to display some user-friendly text instead of an ID number, the user will expect the column to sort by the text he can see, not the underlying ID value which he cannot see.
yep I understand what you mean. Thank you for you help.