简体   繁体   English

获取选定行的 ExtJS4 可编辑网格返回空

[英]ExtJS4 editable grid getting selected row returns empty

Trying to get the selected row index (and set another field value of the record afterwards) on a grid with CellEditing plugin, but getSelection() method returns an empty array.尝试使用 CellEditing 插件在网格上获取选定的行索引(并随后设置记录的另一个字段值),但getSelection()方法返回一个空数组。 I have a listener for select event on the combobox, when that is changed I need to get the index of the edited row.我在 combobox 上有一个 select 事件的侦听器,当该事件发生更改时,我需要获取已编辑行的索引。

...
lazyRender: true,
listClass: 'x-combo-list-small',
listeners: {
    scope: this,
    select: function(field, value, options) {
        var selection = Ext.getCmp('lineItemsGrid').getSelectionModel().getSelection();                                            
        console.log(selection);
    }
}
...

I'm using ExtJS 4.0.2a release.我正在使用 ExtJS 4.0.2a 版本。 I'm a newbie when it comes to ExtJS, so I might be missing something.我是 ExtJS 的新手,所以我可能会遗漏一些东西。

Here is JSFiddle file in cas you want to have a look.这是您想要查看的 JSFiddle 文件。
http://jsfiddle.net/Z6b7a/8/ http://jsfiddle.net/Z6b7a/8/

Any help is greatly appreciated.任何帮助是极大的赞赏。

Thanks谢谢
Oz盎司

You don't need to use the getSelection() method, you can update the record directly from the edit event.您不需要使用getSelection()方法,您可以直接从编辑事件中更新记录。

http://jsfiddle.net/Z6b7a/7/ http://jsfiddle.net/Z6b7a/7/

I've updated the fiddle, and also here is the code to update the record after edit:我已经更新了小提琴,这里也是编辑后更新记录的代码:

edit: function(editor, e, options) {
     e.record.set('light', 'Shade');
     //var selections = Ext.getCmp('lineItemsGrid').getSelectionModel().getSelection();
     //console.log(selections);
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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