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??
Dear Mike,
I am using method 1 of Icomparer. I have created the class as in the attached file.
But meet some problems in ultragrid. Attached photos can descibe my case.
(1) Initial -> init_page.JPG
(2) When I click on column to sort , it show -> after click on column availableQty.JPG
(3) When I click on same column again, it show -> click again on column 3.JPG.
Please help to solve this invalid behavior.
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.
you're welcome!!!
Is this only the solution??
you have to create an IComparer and use it as the sortComparer of the grid
here's a sample of the icomparer
internal class CustomSortComparer : IComparer
{
internal CustomSortComparer()
}
int IComparer.Compare(object x, object y)
// Passed in objects are cells. So you have to typecast them to UltraGridCell objects first.
UltraGridCell xCell = (UltraGridCell)x;
UltraGridCell yCell = (UltraGridCell)y;
//// Do your own comparision between the values of xCell and yCell and return a negative
//// number if xCell is less than yCell, positive number if xCell is greater than yCell,
//// and 0 if xCell and yCell are equal.
hope this helps