Dear all,
I have the column (Datatype=system.string) in ultragrid. It is showing NA or decimal.
Actually the data is decimal (I have changed the value zero to be NA when showing in the grid. 0==> NA). But the sorting does not apply to decimal due to the datatype is string. The sorting is like below:
" 1 , 11, 2, 23, 3, 333, 4, NA " in ascending order. How can I make sorting in decimal with NA ==0 but the showing in the grid is "NA"? Is it possible??
You have two basic options here.
1) If the grid's column's DataType is a string, then you can use an IComparer to handle the sorting of the strings as numbers.
2) If the grid column's DataType is numeric, then the sorting will work correctly, and you will have to handle translating a 0 into "NA". There are a number of ways to do this. If the field is editable by the user, then you could use a DataFilter. If it's not editable by the user, then it would be easier to do this using a CreationFilter to set the Text on the TextUIElement in the cell.
I am trying to use option 2.
But I don't know why the readonly field in ultragrid is always changed from decimal datatype to string datatype. Then the sorting is in string format. Do you know why?? How to overcome this??
Hi,
I'm afraid I am lost. I can see that the screens shots you attached here are showing that the sorting is not working the second time.
But I don't know what you are doing in your code. The only IComparer in the three cs files you attached here is a Comparer for a specific type of object. This is not a Comparer that you could possibly be assigning as a SortComparer on a grid column - it would just blow up when the grid tried to pass a couple of UltraGridCell objects into it.
If the grid is sorting the data by text, then the column's DataType must be a string. The grid does not change the DataType from a numeric type (or any type) into a string.
One thing I did notice that is wrong is that your Comparer is reversing the return value based on the SortOrder. You should not be doing that - or at least it's not something you should do when sorting in the grid.
Dear Mike,
In my attached file,( forms scripts), I debug it and checked that the return values of this.catlist.sort(....).They are correct. I am afraid that there is a collision between mouseclick event and default behavior of ultragrid.
Would that happen??
When I disable the sorting of ultragrid, it works.
But how to make the header column sorting indicator show??
When I am trying to use sort indicator.
if (sortOrder == SortOrder.Ascending) column.SortIndicator = Infragistics.Win.UltraWinGrid.SortIndicator.Ascending; else column.SortIndicator = Infragistics.Win.UltraWinGrid.SortIndicator.Descending;
I find that the default sorting of ultragrid happen, no matter where I set below code.
this.dtgCatItemList.DisplayLayout.Override.HeaderClickAction = HeaderClickAction.Select;
Do you have any methods to work??
It was not clear to me that you were trying to sort the data and not sort the grid rows. But if that's what you want, then you are correct to use the ExternalSortMutli option. This option tells the grid to show the sort indicator but to not actually sort the rows in the grid.
It works when I set HeaderClickAction.ExternalSortMulti