:: Forum >>

Reloading a grid with new columns in AW 2.5

I have a grid in an iframe that for certain operations needs to be reloaded with a different set of columns. To avoid the delay in reloading the entire source of the iframe, I reset the contents of the grid directly, using the following code (variable assignments have been left out for simplicity):

grid.setHeaderText(field_array);
for (loop = 0; loop < num_columns; loop++)
grid.setColumnWidth(column_widths_array[loop],loop);
grid.setColumnCount(num_columns);
grid.setSelectedRows([record_number]);
grid.setCurrentRow(record_number);
grid.setSelectedColumns([0]);
grid.setCurrentColumn(0);
grid.setRowCount(num_records);
grid.setScrollTop(scroll_top);
grid.setCellText([]);
grid.refresh();


The above code worked fine in AW 2.0. But in AW 2.5, the columns get all confused, showing the data in only the first three columns, the remaining columns are blank. I assume it has something to do with the new virtual column scrolling in AW 2.5, but I don't know where to start in figuring out what needs to be reset to get it to work properly. Does anyone know how to reset the virtual column data to reload a grid with new columns?
Randall Severy
Wednesday, December 26, 2007
I dont get your problem, i can reset the grid columns (virtual mode) easy like:

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

obj.setColumnCount(10);
obj.setRowCount(20);
obj.setVirtualMode(true);
document.write(obj);

var reset = new AW.UI.Button;
reset.setControlText("Reset");
reset.onClick = function() {
    obj.setHeaderText(["1", "2", "3"]);
    obj.setColumnCount(3);
    obj.refresh();
}
document.write(reset);
</script>
Paulo Cesar (PC from Brazil )
Friday, December 28, 2007
Randall,
Are you loading a different number of columns each time?
If so, probably need clearModels() and refresh() patch posted in:
(But I am not sure how this affect to version 2.5 ?? Alex?)
/javascript.forum.11480.8/refresh-content-in-grid.html

But if you are working with same columns-count the only thing I can suggest is (like PC said) doing a refresh when all your columns ( or maybe visible ones) are setted, so in your case:

for (loop = 0; loop < num_columns; loop++) {
grid.setColumnWidth(column_widths_array[loop],loop);
if(loop==num_columns){
.....
grid.setColumnCount(num_columns);
grid.refresh();
}
}

hoping it gives some help
Carlos
Friday, December 28, 2007

This topic is archived.


Back to support forum

Forum search