Delete rows that are not checked
Hi,
What i'm trying to do, is create a grid with the first column as checkboxes.
I want the user to select the checkboxes of the rows that the user does NOT want to delete and delete the rows that are NOT checked.
I created my grid and set the first row to a checkbox"
obj.setCellTemplate(new AW.Templates.Checkbox, 0);
//set the values to false
obj.setCellValue(false, 0);
// toggle it to yes and no
obj.setCellText(function(col, row){return this.getCellValue(col, row) ? "yes" : "no"}, 0);
// Then write it.
document.write(obj);
I then created a getChecked method to delete the rows (I would add this function to a button):
function getChecked() {
var knt = 0;
knt = obj.getRowCount();
for(var i= knt - 1; i > -1; i--) {
if(!obj.getCellValue(0,i)) {
obj.deleteRow(i);
}
}
}
This works great for the first time, but the second time i try it, the
obj.getRowCount(); does not alway gives the right knt and decrements to 0 and for the rows, the checkbox values are are not setting to the proper checked and unchecked state.
Does anyone know how to fix this or is there a better way to do this?
Thanks for your time.
What i'm trying to do, is create a grid with the first column as checkboxes.
I want the user to select the checkboxes of the rows that the user does NOT want to delete and delete the rows that are NOT checked.
I created my grid and set the first row to a checkbox"
obj.setCellTemplate(new AW.Templates.Checkbox, 0);
//set the values to false
obj.setCellValue(false, 0);
// toggle it to yes and no
obj.setCellText(function(col, row){return this.getCellValue(col, row) ? "yes" : "no"}, 0);
// Then write it.
document.write(obj);
I then created a getChecked method to delete the rows (I would add this function to a button):
function getChecked() {
var knt = 0;
knt = obj.getRowCount();
for(var i= knt - 1; i > -1; i--) {
if(!obj.getCellValue(0,i)) {
obj.deleteRow(i);
}
}
}
This works great for the first time, but the second time i try it, the
obj.getRowCount(); does not alway gives the right knt and decrements to 0 and for the rows, the checkbox values are are not setting to the proper checked and unchecked state.
Does anyone know how to fix this or is there a better way to do this?
Thanks for your time.
DP
July 6,