3.2.0

Sorting a numeric column with string data

If I have a column with numbers and some of the rows only has "n/a" the sort order of that column is not performed correctly. Example:

RANK WebSite
---------------
9 sitea.com
3 siteb.com
n/a sitec.com
7 sited.com

When I order by the RANK column the sort order becomes wrong. One possible solution to correct this would be to force the sort method of the column.

In the example you could have some instruction to say that the order of RANK column is "numeric" and any value in that column that is not a number would be a high number or blank, in order to sort it correctly.

For example: If I had an instruction to say that the RANK column is to be sorted in numeric format and any value on that column that is not a number would be treated as if it had the value of 999999, the sort order would be perfect. As the value is "n/a" (not available) it would be the last in an ascending order or the first in a descending order.

Carlos
December 19,
The grid uses data/text property for display and data/value for sorting. By default data/value is equal to data/text. In your case you can make data/text and data/value different and your sort will be independent of display text:

// provide formatted text for display
obj.setDataText(function(i, j){return i + " " + myData[i][j]});

// provide clean value for sorting
obj.setDataValue(function(i, j){return myData[i][j]});

Alex
Alex (ActiveWidgets)
December 19,

This topic is archived.

See also:


Back to support forum