View Full Version : Detecting the value of a checkbox in a grid header
ssinai
11 Oct 2011, 2:32 PM
I'm using a CheckboxSelectionModel to create a column of checkboxes in a grid.
I'm using the onHeaderClick(GridEvent<M> se) method to detect when the checkbox in the column header is clicked, but I can't figure out how to detect whether the header checkbox was just selected or deselected. Does anyone know how to do this?
micgala
12 Oct 2011, 12:03 AM
Hi. If you check the onHeaderClick implementation, you will see how it checks that:
protected void onHeaderClick(GridEvent<M> e) {
El hd = e.getTargetEl().getParent();
boolean isChecked = hd.hasStyleName("x-grid3-hd-checker-on");
.....
ssinai
13 Oct 2011, 10:59 AM
Thanks. Now I need to be able to override the CheckedBoxSelectionModel's updateHeaderCheckBox() and setChecked(boolean checked) methods so that I can control whether the checkbox in the column header is checked or not. Unfortunately, both those methods are declared private, so I can't override their behavior.
The issue is that I have a grid spread across several pages, and use a PagingToolBar to move between pages. The column header checkbox for a particular page is deselected if any of the checkboxes in the grid on the current page are deselected, but I need to be able to deselect the header checkbox if a checkbox on any page is deselected - not just the visible page.
If those two methods were declared protected or public rather than private, I'd be in good shape. The private declarations are really screwing me up.
Powered by vBulletin® Version 4.1.5 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.