Toggle All
I know how to do a select All.
But how can I do a toggle all, ie turn every row off that is on and on that is off.
Thanks.
Dale Fraser
November 28,
Any ideas?
Somehow should be able to loop through each entry check it's current state and reverse it, but I can't figure it out.
Dale Fraser
November 29,
I added three function to my code to do exactly this (including selectAll)
Each function is called by a button and/or hot key.
function invertSelection() {
var rSelected = obj.getSelectedRows();
if (rSelected.length == obj.getRowCount()) {
obj.setRowSelected( );
obj.refresh();
return;
}
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();
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();
obj.setSelectedRows(newSelectedRows);
obj.refresh();
grid2.focus();
}
function deSelectAll() {
obj.setSelectedRows([]);
obj.clearSelectionModel();
obj.refresh();
grid2.focus();
}
function selectAll(){
var newSelectedRows = new Array();
for (j=0; j <obj.getRowCount(); j++){
newSelectedRows.push(j) ;
}
obj.setSelectedRows(newSelectedRows);
obj.refresh();
grid2.focus();
}
Colin P
May 16,