3.0.4

Setting cell contents with setCellText - not updating screen

In a onCellValidated event, I'm trying to set the cell's contents, overriding what is there. obj.setCellText(value, col, row) works OK but does not refresh the screen (though a column sort will show the new data.). So I tried obj.refresh() after the setCellText, and that caused a Javascript error "Line 31 Error e.parentNode is null or not an object".
Here's some sample code:

<script>

var obj = new AW.UI.Grid;
obj.setSize(800, 250);
obj.setCellText(function(i, j){return j + "-" + i});
obj.setHeaderText("header");

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

obj.setCellEditable(true);

obj.onCellValidated = function(value, col, row){
obj.setCellText("x", col, row);
obj.refresh();
}

document.write(obj);


</script>
LanceH
April 17,
Hi,
I´m testing the active widgets 2.0 and i have the same problem.
how I can update a cell with the sum of a row values after the grid was loaded?

I tried with:

obj.onCellValidated = function(value, col, row){
this.setCellText(sumRowValues(this, row), this.getColumnCount()-1, row);
this.refresh();
}
Raúl Baltazar
April 19,
Cell text update is blocked during editing, which is a bug (there should be a better solution). For now if you want to update the edited cell this code will work -

obj.onCellValidated = function(value, col, row){

        this.setCellText("...", col, row);

        // update cell with modified text (bug fix)
        var input = this.getCellTemplate(col, row).getContent("box/text").element();
        var text = this.getCellText(col, row);
        if (AW.gecko){
            input.value = text;
        }
        else {
            input.innerHTML = text;
        }
    }


If you have to update other cells - use onCellEditEnded event instead of onCellValidated, that one should work fine because at this point the editing is finished and cell template updates no longer blocked.
Alex (ActiveWidgets)
April 19,
Thanks Alex, the onCellEditEnded event works for me.
Raúl Baltazar
April 20,

This topic is archived.

See also:


Back to support forum

Search

Version 2

Looking for AW 2.6 ?
The old site is here.