ExtJs checkboxselectionmodel

I use GridPanel w / CheckboxSelectionModel to select an item. In edit mode, when some parameters have already been selected, I try to pre-select the lines when loading the form.

...
store.load();
//curSelections is an array containing the some ForeingKey IDs of the selected records.
...

for (var i = 0; i < curSelections.length; i++) {
    console.log('found personel ' + curSelections[i] + ' at ', 
                 store.findExact('Id', curSelections[i]));
    selectedRecords.push(store.findExact('Id', curSelections[i]));
}
//everything is fine according to console log.
checkGrid.getSelectionModel().selectRecords(selectedRecords, true);
formWin.show();

this does not work.

I try to call "selectRecords" also on some other page / form events, but none of them even fire.

grid.addListener('show',
grid.on('show',
formWin.on('activate',
formWin.on('show',....

some grid code

var sm = new Ext.grid.CheckboxSelectionModel({
        singleSelect: false,
        sortable: false,
        checkOnly: true
    });
    checkGrid = new Ext.grid.GridPanel({
        xtype: 'grid',
        store: obPersonelStore,
        loadMask: true,
        layout: 'fit',
        height: 120,
        id: 'grdIsBirimiPersonelListesi',

        columns: [
            sm,
            {

I missed something simple, but I don’t know what it is. Any help is welcome.

+3
source share
3 answers

Store.findExact . SelectionModel. selectRecords . selectRows ? , store. getAt, , selectRecords().

+3

:

var store = new Ext.data.Store({
  ...
});
var grid = new Ext.grid.GridPanel({
  store: store,
  ...
});
store.on('load', function() {
  grid.getSelectionModel().selectFirstRow();
});
store.load();
+1

100% , . :

? selectAll() CheckboxSelectionModel.

, , , , , selectRecords(), selectRows().

0
source

Source: https://habr.com/ru/post/1719074/


All Articles