:: Forum >>

Query on sort behavior

the issue I am facing is, after I sort the grid data (by clicking column header), if I select row it does not return the correct selected row index in term of actual data (array index) set to the grid.

say if set following data to grid:
var myData = [
["C", "aa", "4313"],
["A", "bb", "5313"],
["B", "cc", "1313"],
["D", "dd", "3313"]
];

So, grid contain following column value for first column:
C
A
B
D

After sorting column based on first column, it shows:
A
B
C
D

Now if I click of 3rd row, the obj.onCellClicked prompt me value "0" (which is actually pointing that 'C' was at 0h index of array).
obj.onCellClicked = function(event, col, row){
alert("Row selected: " + row);
};

My requirement is it should return me "3" as this is now 3rd row.

How this can be done.

I tried following:

obj.onRowIndicesChanged = function(value){
var innerArr = new Array();
var temp = new Array();
for(i=0;i<value.length;i++) {
var arrIndex = value[i];
temp.push(i);
innerArr.push(myData[arrIndex]);
}
myData=innerArr;
obj.clearScrollModel();
obj.clearSelectedModel();
obj.clearSortModel();
obj.clearRowModel();
obj.setRowCount(myData.length);
obj.setCellText(myData);
obj.refresh();
};

the issue with this is, after this function exits, the row position displayed are not correct. It shows
3
1
2
4

it is correct after obj.refresh (if I put alert after obj.refresh(), at that time it shows correct order). as soon as I click OK on alert, row serial number becomes incorrect.

please let me know how to resolve this issue
TS
Monday, September 12, 2011

This topic is archived.


Back to support forum

Forum search