简体   繁体   中英

ExtJS Grid selection getSelectionModel() doesn't seems to work

I am encountering a strange behaviour regarding my grid selection:

I have a simple grid, but when I select a record, I do:

var grid = this.getExternrulesgrid();  
var records = grid.getSelectionModel().getSelection();
var rec = this.getSelectedExternRule();

But for some reason, records is empty?!

Do you have any idea as to why?

Thank you!!

在此处输入图片说明在此处输入图片说明在此处输入图片说明

Their are various ways you can get the selected record.

1.You can use selectionchange event listener.

selectionchange( this, selected, eOpts ){
}

Here, selected : The selected records.

2.Using selection model on some action

selected=[];
selctn = grid.getSelectionModel();
var s = selctn.getSelection();
Ext.each(s, function(item) {
    selected.push(item);
});

You will be getting the array of selected records in selected array.

Note: Check your grid object.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM