:: Forum >>

Sort no working with custom setCellData function

Hello,

Using 2.0.1, Consider the exhibit:
var data = [['a','z','1'],['b','y','2'],['c','x','3']];
var getData = function(col,row){return data[row][col]};

var grid2 = new AW.Grid.Extended;
grid2.setId("grid2");
grid2.setCellData(getData);
grid2.setHeaderText("header");
grid2.setColumnCount(2);
grid2.setRowCount(3);
grid2.refresh();


With this simple code sample, row sorting works by clicking on the headers.
Now, if I replace:
var getData = function(col,row){return data[row][col]};
with:
var getData = function(col,row){return data[row][col+1]};
... sorting is not working anymore! (tested with IE 6 / Firefox 2.0)
How can I have sorting work as expected?

Thanks
Frédéric
Monday, December 4, 2006
You should convert the index to Number here -

var getData = function(col,row){return data[row][Number(col)+1]};
Alex (ActiveWidgets)
Monday, December 4, 2006
Great, thank you Alex!
Frédéric
Tuesday, December 5, 2006

This topic is archived.


Back to support forum

Forum search