如何在 BufferedStore Grid 中附加选择模型

How to attach selection model in BufferedStore Grid

我正在尝试在 extjs 网格中附加复选框模型。我正在使用缓冲存储,但它没有发生。我在网格配置中使用 selModel :checkBoxSelMod, 清除 var checkBoxSelMod = new Ext.grid.CheckboxSelectionModel(); 但我不明白为什么它会抛出。 My working Fiddler

你可以使用这个:

{
            xtype:'checkcolumn',
            dataIndex:'selection',
            listeners:{
                checkchange:function(checkbox , rowIndex , checked , record , eOpts){
                    if(checked){
                        var selections=grid.getSelection();
                        selections.push(record);
                        grid.setSelection(selections);
                    }else{
                        var selectionsDelete=grid.getSelection();
                        Ext.Array.removeAt(selectionsDelete,selectionsDelete.indexOf(record))
                        grid.setSelection(selectionsDelete);
                    }                             
                }
            }
        }

记得在网格上多选广告:

selModel: {mode: 'MULTI'}

这里是fiddlehttps://fiddle.sencha.com/#fiddle/1jd2

使用 grid.getSelection() 来选择记录。