enveetee
2014-10-29T09:46:13Z
I have a column of numeric data represented as strings:

"1.00"
"10.01"
"2.00"
"19.00"


Currently iGRID sorts this as:
1.00
10.00
19.00
2.00
Which I know is correct as it is comparing strings

How can I sort this in numerical order please:
1.00
2.00
10.00
19.00

Thanks
Igor/10Tec
2014-10-30T07:30:06Z
As we know, you are evaluating iGrid to replace SGrid. It looks like you are still thinking in the terms of the latter control while working with iGrid, and you may build a more complicated solution with iGrid than it should be.

Yes, you can have only texts in SGrid cells, but iGrid allows you to store values in cells in their native format. Your values are in fact numeric values, and to sort them properly, you just need to add them to iGrid "as is" (Long, Single, etc).

***

If you cannot do that (for instance, your values come from a database), then you can solve your problem using custom sort. To do that, set the column sort type (the ColSortType property) to igSortCustom and compare the values as numeric values in the CustomSort event - something like that:

Private Sub iGrid1_CustomSort(ByVal lCol As Long, ByVal lRow1 As Long, ByVal lRow2 As Long, v1 As Variant, v2 As Variant, lCompareResult As Long)
   lCompareResult = Val(v1) - Val(v2)
End Sub
enveetee
2014-10-30T07:46:14Z
Originally Posted by: Igor/10Tec 

As we know, you are evaluating iGrid to replace SGrid. It looks like you are still thinking in the terms of the latter control while working with iGrid, and you may build a more complicated solution with iGrid than it should be.

Yes, you can have only texts in SGrid cells, but iGrid allows you to store values in cells in their native format. Your values are in fact numeric values, and to sort them properly, you just need to add them to iGrid "as is" (Long, Single, etc).

***

If you cannot do that (for instance, your values come from a database), then you can solve your problem using custom sort. To do that, set the column sort type (the ColSortType property) to igSortCustom and compare the values as numeric values in the CustomSort event - something like that:

Private Sub iGrid1_CustomSort(ByVal lCol As Long, ByVal lRow1 As Long, ByVal lRow2 As Long, v1 As Variant, v2 As Variant, lCompareResult As Long)
   lCompareResult = Val(v1) - Val(v2)
End Sub




Thanks Ivor - I have purchased the ActiveX package