How to Bind dataIndex to Select All check box

2019-07-26 15:53发布

问题:

I am trying to bind checkbox field to gird with select all options -

 xtype: 'grid',
 store: {
        type: 'webapi',
        api: {
            read: 'api/Report/GetIfo'
        },
        autoLoad: true,
    },
 columns: [    
        { header: 'Name', dataIndex: 'first_name'}
    ], 
    selModel: {
                selType: 'checkboxmodel',    
                //dataIndex:'flag',
                //showHeaderCheckbox: true
            }

I am trying to bind the dataIndex to it so that when grid is loaded, respective checkbox will be selected.

I tried by using

selModel: {
                selType: 'checkboxmodel',    
                //dataIndex:'flag',
                //showHeaderCheckbox: true
            }

But no success. Please suggest me on how to bind the dataIndex here.

回答1:

My suggestion to you is use https://docs.sencha.com/extjs/5.0/5.0.1-apidocs/#!/api/Ext.grid.column.Check

Flag have to true or false if not, you should convert in your model like

{ name: 'flag', type: 'bool',
        convert: function (v) {
            return (v === "True" || v === true) ? true : false;
        }
    }


标签: Extjs extjs5