function invertSelection() {
var rSelected = obj.getSelectedRows();
// clear all if all selected
if (rSelected.length == obj.getRowCount()) {
obj.setRowSelected( );
obj.refresh();
return;
}
//CREATE HASH OF ALL SELECTED ROWS
var hash = new Object();
for (var i=0; i<rSelected.length; i++) {
if (hash[rSelected[i]] != 1) {
hash[rSelected[i]] = 1
}
}
var newSelectedRows = new Array();
var rIndices = obj.getRowIndices();
//CREATED AN ARRAY OF UNSELECTED ROWS
// NOTE: DIFFERENT LOGIC IF ROWS HAVE BEEN SORTED
if (""==rIndices||null==rIndices ){
for (j=0; j <obj.getRowCount(); j++){
if (hash[j] != 1){
newSelectedRows.push(j) ;
}
}
}else{
for (k=0; k<rIndices.length; k++){
if (hash[rIndices[k]] != 1){
newSelectedRows.push(rIndices[k]) ;
}
}
}
deSelectAll(); // DESELECT ALL ROWS
obj.setSelectedRows(newSelectedRows); //SET NEW ROWS SELECTED
obj.refresh();
grid2.focus(); // grid2 IS THE NAME OF MY GRID
}
function deSelectAll() {
obj.setSelectedRows([]);
obj.clearSelectionModel();
obj.refresh();
grid2.focus(); // grid2 IS THE NAME OF MY GRID
}
function selectAll(){
var newSelectedRows = new Array();
for (j=0; j <obj.getRowCount(); j++){
newSelectedRows.push(j) ;
}
obj.setSelectedRows(newSelectedRows);
obj.refresh();
grid2.focus(); // grid2 IS THE NAME OF MY GRID
}
This topic is archived.