Correctly Formatting Sortable Percentages
I am trying to correctly format a column of percentages (v2.0b1), with the requirement that they still sort correctly.
Starting with the code in the following topic, I tried to add percentage formatting (my modified code is below): http://www.activewidgets.com/javascript.forum.8193.2/sorting-numbers.html
I know that I can manually format the data from the js-array before placing in the grid, but then sorting does not work.
There is another support topic that addresses this problem when loading from XML by applying the formatting to the 'xml table', but I am loading from a js-array.
Note that the code below does sort correctly because of the explicit setting of the column's cell format to AW.Formats.Number. However, the format string ("#,###.00%") does not correctly format the data. I did try variations on the format string to no avail.
Do you have any suggestions? Any help would be appreciated.
My (non-working) modifications are here:
Starting with the code in the following topic, I tried to add percentage formatting (my modified code is below): http://www.activewidgets.com/javascript.forum.8193.2/sorting-numbers.html
I know that I can manually format the data from the js-array before placing in the grid, but then sorting does not work.
There is another support topic that addresses this problem when loading from XML by applying the formatting to the 'xml table', but I am loading from a js-array.
Note that the code below does sort correctly because of the explicit setting of the column's cell format to AW.Formats.Number. However, the format string ("#,###.00%") does not correctly format the data. I did try variations on the format string to no avail.
Do you have any suggestions? Any help would be appreciated.
My (non-working) modifications are here:
var data = [
["xxx", "40000.02"],
["yyy", "500.042"],
["zzz", "10.283"]
]
var obj = new AW.UI.Grid;
obj.setCellText(data);
obj.setColumnCount(2);
obj.setRowCount(3);
var number = new AW.Formats.Number;
number.setTextFormat("#,###.00%");
obj.setCellFormat(number, 1);
document.write(obj);
David Parr
November 3,