Javascript 如何从使用复选框模型的 ExtJS 网格中获取选定的记录

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/6749211/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-23 23:01:17  来源:igfitidea点击:

How can I get selected records from ExtJS grid that uses a checkboxmodel

javascriptextjs

提问by Steve

Given that I've got a ExtJS grid using a CheckBoxModel, what is the best way to get a list of all the records where the checkbox is checked?

鉴于我有一个使用CheckBoxModel的 ExtJS 网格,获取复选框被选中的所有记录列表的最佳方法是什么?

回答by pablodcar

In ExtJS 4, to select records in a grid with selection model as Ext.selection.CheckboxModel do:

在 ExtJS 4 中,要在选择模型为 Ext.selection.CheckboxModel 的网格中选择记录,请执行以下操作:

var s = grid.getSelectionModel().getSelection();
// And then you can iterate over the selected items, e.g.: 
selected = [];
Ext.each(s, function (item) {
  selected.push(item.data.someField);
});

I hope this helps

我希望这有帮助

回答by aswininayak

simply by using getSelection()like this :

只需getSelection()像这样使用:

var selectedRecordsArray = grid.getView().getSelectionModel().getSelection();

回答by zengsong

var arrayList=[],
 selected=Ext.getCmp('wpDetaPrdsDetailGrid').getView().getSelectionModel().getSelection();
                    Ext.each(selected, function (item) {
                       arrayList.push(item.data);                    
});

回答by seasonedgeek

Your grid checkbox questionis addressed on the the Sencha Ext JS 3.x Community Forum.

您的网格复选框问题已在 Sencha Ext JS 3.x 社区​​论坛上解决。

回答by Dipen Soni

var SelectedCheckbox=grid.getSelectionModel();
for(i=0;i<SelectedCheckbox.selections.length;i++){
    console.log(SelectedCheckbox.selections.items[i].data.field_name);
}