obj.selectAllRows = function(){
// save event handlers
var onRowSelectedChanged = this.onRowSelectedChanged;
var onRowStateChanged = this.onRowStateChanged;
// cancel events
this.onRowSelectedChanged = function(){return 1};
this.onRowStateChanged = function(){return 1};
this.setRowSelected(true);
this.setRowState("selected");
var i, rows = [], max = this.getRowCount();
for (i=0; i<max; i++){
rows.push(i);
}
this.setSelectedRows(rows);
// restore event handlers
this.onRowSelectedChanged = onRowSelectedChanged;
this.onRowStateChanged = onRowStateChanged;
// repaint the grid content
this.refresh();
}
obj.selectNoRows = function(){
// save event handlers
var onRowSelectedChanged = this.onRowSelectedChanged;
var onRowStateChanged = this.onRowStateChanged;
// cancel events
this.onRowSelectedChanged = function(){return 1};
this.onRowStateChanged = function(){return 1};
this.setRowSelected(false);
this.setRowState("");
var i, rows = [], max = this.getRowCount();
for (i=0; i<max; i++){
rows.push(i);
}
this.setSelectedRows(rows);
// restore event handlers
this.onRowSelectedChanged = onRowSelectedChanged;
this.onRowStateChanged = onRowStateChanged;
// repaint the grid content
this.refresh();
}
var i, rows = [], max = this.getRowCount();
for (i=0; i<max; i++){ rows.push(i); }
this.setSelectedRows(rows);
this.setSelectedRows([]);
obj.selectNoRows = function(){
// save event handlers
var onRowSelectedChanged = this.onRowSelectedChanged;
var onRowStateChanged = this.onRowStateChanged;
// cancel events
this.onRowSelectedChanged = function(){return 1};
this.onRowStateChanged = function(){return 1};
this.setRowSelected(false);
this.setRowState("");
this.setSelectedRows([]);
// restore event handlers
this.onRowSelectedChanged = onRowSelectedChanged;
this.onRowStateChanged = onRowStateChanged;
// repaint the grid content
this.refresh();
}
function FastSelectRows(grid, selectedRows)
{
// Cache then supress selection event handlers.
var onRowSelectedChanged = grid.onRowSelectedChanged;
var onRowStateChanged = grid.onRowStateChanged;
grid.onRowSelectedChanged = function() {return 1;};
grid.onRowStateChanged = function() {return 1;};
if (selectedRows.length == grid.getRowCount())
{
// All of of the grid is selected.
grid.setRowSelected(true);
grid.setRowState("selected");
}
else
{
// At least some of the grid is unselected.
grid.setRowSelected(false);
grid.setRowState("");
for (var i in selectedRows)
{
grid.setRowState("selected", selectedRows[i]);
}
}
grid.setSelectedRows(selectedRows);
// Restore the cached event handlers
grid.onRowSelectedChanged = onRowSelectedChanged;
grid.onRowStateChanged = onRowStateChanged;
}
This topic is archived.