Search code examples
javascriptextjsextjs4extjs4.1extjs4.2

Checkbox selection model - check column header text


I have a checkbox selection model that I am using on a gridpanel. I have configured the CheckboxModel like so:

Ext.create('Ext.selection.CheckboxModel', {
    mode: 'Single',
    checkOnly: true,
    showHeaderCheckbox: false
});

This configuration allows the user to select only one record from the gridpanel. I have removed the checkbox in the header since I want the user to have to explicitly check the box in the record row. Now I have just a blank header in that column....is there any way to add text to that header column? From what I can tell it seems like my only options are to either leave the checkbox in the header or remove it and have a blank column header...is that correct?


Solution

  • You can override the getHeaderConfig method of the CheckboxModel, like:

    Ext.define('Fiddle.override.selection.CheckboxModel', {
        override: 'Ext.selection.CheckboxModel',
    
        getHeaderConfig: function() {
            return Ext.apply(this.callParent(arguments), {
                width: 100,
                header: 'Select'
            });
        },
    
    });
    

    Working example: https://fiddle.sencha.com/#fiddle/1b3g