set cell colors in function, but not in selected row
I need to set the cell background color in a function, as shown in the following simple example. (In my real app, the function is more complex).
But I don't want my function to change the color of cells in the selected row, I want those cells to use the normal highlight color. The following example works, but it needs to call refresh() whenever the selected row changes. This causes an ugly flicker if the table is large. Is there any way to do this without the refresh() ??
thanks
But I don't want my function to change the color of cells in the selected row, I want those cells to use the normal highlight color. The following example works, but it needs to call refresh() whenever the selected row changes. This causes an ugly flicker if the table is large. Is there any way to do this without the refresh() ??
thanks
<script>
var tbl = new AW.UI.Grid;
tbl.setSelectionMode("single-row");
tbl.setVirtualMode(true);
tbl.setCellText(function(col, row){return row + "," + col;});
tbl.setHeaderText("header");
tbl.setColumnCount(6);
tbl.setRowCount(2000);
// customize cell colors, except in selected row
tbl.getCellTemplate().setStyle("background", function(){
var col = this.$0;
var row = this.$1;
var selrows = tbl.getSelectedRows();
if (selrows && row == selrows[0])
return "highlight";
return (row+col) % 2 == 0 ? "white" : "red";});
// i need this else selected row is not highlighted (yuck)
tbl.onSelectedRowsChanged = function () {tbl.refresh();};
document.write(tbl);
</script>
CK
April 7,