View Full Version : [CLOSED] CheckboxSelectionModel override updateHeaderState

Feb 14, 2015, 8:39 PM
I have a GridPanel using the CheckBoxSelectionModel. I have read several threads and have been able to define CSS to replace the checkbox with icons if the row should not be selected via the GridView GetRowClass. This is based on a field in the store named AccessLevel. If it is a 0 I assign wsFileLink_na css (which shows the BulletCross icon) and if it is a 1 I assign wsFileLink_Link (which shows the Link icon). If the value is 2 no css is assigned and thus the checkbox is available to be checked. I defined additional CSS to make sure everything was aligned properly.

The last hurdle is when you select the Header checkbox. It selects all the rows that have checkboxes, but it doesn't stay checked because not everything in the store is checked (basically the disabled rows).

The following thread discussed it directly, but Daniil wasn't able to provide an example. I have other GridPanels using the CheckBoxSelectionModel so I need to be careful with any override so as not to break the other GridPanel stores. Any additional thoughts 2 months later?

Issue with grid panel header check box in CheckboxSelectionModel (https://forums.ext.net/showthread.php?48961-CLOSED-issue-with-grid-panel-header-check-box-in-CheckboxSelectionModel)

Below is the private method updateHeaderState for Ext.selection.CheckboxModel

updateHeaderState: function() {

var me = this,
store = me.store,
storeCount = store.getCount(),
views = me.views,
hdSelectStatus = false,
selectedCount = 0,
selected, len, i;

if (!store.buffered && storeCount > 0) {
selected = me.selected;
hdSelectStatus = true;
for (i = 0, len = selected.getCount(); i < len; ++i) {
if (!me.storeHasSelected(selected.getAt(i))) {
hdSelectStatus = storeCount === selectedCount;

if (views && views.length) {

Feb 15, 2015, 3:54 AM
Hello, Chris Wolcott!

I had an idea, not sure that it will do. But, worth seeing: reply to the thread you pointed (http://forums.ext.net/showthread.php?48961-CLOSED-issue-with-grid-panel-header-check-box-in-CheckboxSelectionModel&p=250341&viewfull=1#post250341).

I believe you can work your logic to make that work. You can do anything you want to the checkbox. If you wanna keep it there (so you can check the header box) but not show it at all, just change the custom cell style to style="display:none" and you'll have a fully functional header checkbox without hurting the selectionModel.

Remember, you have to handle allowed and unallowed checked cells after submission -- just remove the cells the user should not have selected and you are also avoiding power users from fiddling with javascript and bypassing your logic.

I hope that helps!

Feb 16, 2015, 6:50 PM
Please go ahead and close this thread. I have posted my final comments on the related thread.

Issue with grid panel header check box in Issue with grid panel header check box in CheckboxSelectionModel (https://forums.ext.net/showthread.php?48961-CLOSED-issue-with-grid-panel-header-check-box-in-CheckboxSelectionModel).

Feb 16, 2015, 8:00 PM
Thanks for letting us know, Chris Wolcott. Closed. :)