David David - 1 month ago 9
Javascript Question

How to attach selection model in BufferedStore Grid

I am trying to attach checkbox model in extjs grid. I am using Buffered Store but it is not happening. I declear

var checkBoxSelMod = new Ext.grid.CheckboxSelectionModel();
then in grid configuration using
selModel :checkBoxSelMod,
but I don't understand why it is throwing. My working Fiddler

Answer

You can use this:

{
            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);
                    }                             
                }
            }
        }

Remember to ad multi selection on grid:

selModel: {mode: 'MULTI'}

Here is a fiddle https://fiddle.sencha.com/#fiddle/1jd2

Use grid.getSelection() to get records selected.

Comments