Check all checkboxes in a column
Making the following changes or additions to grid.htm in quickref folder gives the grid an extra column, populated with checkboxes, all of which can be checked or unchecked with the checkbox in the second header row.
While this appears to work, one consideration is that the loop that sets the value of the checkbox in the templated cell seems very slow on large datasets. It would be better to be able to set the value for the whole column at once i.e. just using
This nearly works, but there seems to be a problem in that, if a checkbox in the grid is checked prior to them all being checked (using the header checkbox), on unchecking all (again using the header checkbox) this particular box remains checked - in other words it retains its state regardless of the event action. Any views on overcoming this would be greatly appreciated.
Will
// create extra column
obj.setColumnCount(6);
// add checkboxes to each row in this extra column
obj.setCellTemplate(new AW.Templates.Checkbox, 5);
// create checkbox for header row
checkbox = new AW.UI.Checkbox;
// put this in the 2nd header row
obj.setHeaderText(["Sub 0", "Sub 1", "Sub 2", "Sub 3", "Sub 4",checkbox], 1);
// set up event for this checkbox that, on value change, it updates the checkboxes in the column
var num_rows = obj.getRowCount();
checkbox.onControlValueChanged = function(value){
for (i=0; i<num_rows; i++){ obj.setCellValue(value,5,i);
}
obj.refresh();
};
While this appears to work, one consideration is that the loop that sets the value of the checkbox in the templated cell seems very slow on large datasets. It would be better to be able to set the value for the whole column at once i.e. just using
checkbox.onControlValueChanged = function(value){ obj.setCellValue(value,5); obj.refresh();
};
This nearly works, but there seems to be a problem in that, if a checkbox in the grid is checked prior to them all being checked (using the header checkbox), on unchecking all (again using the header checkbox) this particular box remains checked - in other words it retains its state regardless of the event action. Any views on overcoming this would be greatly appreciated.
Will
Will
November 2,