3.2.0

Adjust alternating row colors after delete

I would rather not refresh as it takes times and changes the position of the grid (even if you set focus).

How do you get the current background color setting of a particular row. If I can test against that I can get it, but my attempts to find that answer have proved fruitless.

Michael
September 25,
found the solution

for (var i=line_number_deleted; i<rowcount i++){
obj.getRowTemplate(i).refresh();
}
Michael
September 25,
yes, you could also try refreshClasses() method instead of refresh(). Also if you are using large grid with virtual scrolling than it make sense to stop at the last rendered row - test for obj.getRowTemplate(i).element(). You should also use row index instead of display position - those two might be different after sorting.

var obj = new AW.UI.Grid;
obj.setCellData(function(col, row){return col + "." + row});
obj.setHeaderText("header");

obj.setColumnCount(10);
obj.setRowCount(1000);

document.write(obj);


// delete row on double click
obj.onRowDoubleClicked = function(event, rowIndex){

    var rowPosition = this.getRowPosition(rowIndex);

    this.deleteRow(rowIndex);

    var rowCount = this.getRowCount();
    var rowIndices = this.getRowIndices();
    var i, index;

    for (i=rowPosition; i<rowCount; i++){
        index = rowIndices ? rowIndices[i] : i;
        this.getRowTemplate(index).refreshClasses();

        if (!this.getRowTemplate(index).element()){
            break;
        }
    }
}
Alex (ActiveWidgets)
September 26,
Thanks refreshclasses is much faster and looks cleaner.
Michael
September 26,

This topic is archived.

See also:


Back to support forum