Sunday, August 30, 2009

Table Column Sort type settings

Have you ever had to show a string attribute in a table as a column, and had to sort it as a numeric value.??

If yes, you will know, that when sorting this column, you see that numbers get sorted as alphabets. Here is what i mean. If you have the values, 1,12,15,23,103, this will be order in which the number will appear after the sorting in ascending order, 1,12,15,103,23.

This happens because the numbers are treated as alphabets and since 2 is greater than 1, 23 is displayed last.

How to fix this????

Obviously we have to make sure that the values are treated as numbers and not alphabets while sorting happens.
The way to do this is to modify the table column definition and add a property "sorttype" to the column. Here is the mql to modify the existing table definition.

modify table system column modify add property "sorttype" "numeric" ;


Make sure to reload cache after executing this mql ..