javascript 如何获取gridPanel单元格值?扩展程序

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/11467060/
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-10-26 13:19:59  来源:igfitidea点击:

How to get gridPanel cell value? ExtJs

javascriptextjs

提问by Kliver Max

I have a gridPanel with ColumnModel. One of this columns is ActionColumnwith buttons. And i want by click a button get a cell value from cell in same row with this button? How to do this?

我有一个带有ColumnModel. 其中一列ActionColumn带有按钮。我想通过单击按钮从与此按钮位于同一行的单元格中获取单元格值?这个怎么做?

My ActionColumn

我的行动专栏

{
        xtype: 'actioncolumn',
        width: 50,
        items: [{
               icon   : url_servlet+'externals/gxp/src/theme/img/pencil.png', 
            tooltip: 'Редактировать участок',
            handler: function(grid, rowIndex, colIndex) {
            alert("DAMACIA!!!!");
           }

回答by Jan Korenek

You have all you need in handler params

您拥有处理程序参数所需的一切

handler: function(grid, rowIndex, colIndex) {
            var row = grid.getStore().getAt(rowIndex);
            console.log(row);
           }

The code above will give you the row, so you just need to select desired cell.

上面的代码会给你行,所以你只需要选择所需的单元格。

If you enforce selection before clicking actioncolumn you can also use code below. But be aware by default clicking on actioncolumn doesn't fire selection, so while clicking actioncolumn an entirely different row can be selected or even no column can be selected at all.

如果您在单击 actioncolumn 之前强制选择,您还可以使用下面的代码。但是请注意,默认情况下单击 actioncolumn 不会触发选择,因此在单击 actioncolumn 时可以选择完全不同的行,甚至可以根本不选择任何列。

grid.getSelectionModel().getSelection()