[CLOSED] CheckboxSelectionModel override updateHeaderState

  1. #1

    [CLOSED] CheckboxSelectionModel override updateHeaderState

    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

    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))) {
                        break;
                    }
                    ++selectedCount;
                }
                hdSelectStatus = storeCount === selectedCount;
            }
                
            if (views && views.length) {
                me.toggleUiHeader(hdSelectStatus);
            }
        }
    Last edited by fabricio.murta; Feb 16, 2015 at 7:59 PM. Reason: [CLOSED]
  2. #2
    Hello, Chris Wolcott!

    I had an idea, not sure that it will do. But, worth seeing: reply to the thread you pointed.

    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!
    Fabrício Murta
    Developer & Support Expert
  3. #3
    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.
  4. #4
    Thanks for letting us know, Chris Wolcott. Closed. :)
    Fabrício Murta
    Developer & Support Expert

Similar Threads

  1. Override properties
    By bit9bug in forum 2.x Help
    Replies: 0
    Last Post: Jan 28, 2013, 2:01 PM
  2. Calendar Override
    By Avatarus in forum 1.x Help
    Replies: 1
    Last Post: Sep 28, 2012, 1:18 PM
  3. Override Ext.net theme
    By Nhím Hổ Báo in forum 1.x Help
    Replies: 1
    Last Post: May 02, 2012, 9:31 PM
  4. Replies: 1
    Last Post: Aug 13, 2010, 5:09 PM
  5. how to override in formpanel ?
    By jhenriquecosta in forum 1.x Help
    Replies: 1
    Last Post: Feb 08, 2010, 11:04 AM

Posting Permissions