简体   繁体   English

Extjs 6-获取网格面板单元格值

[英]Extjs 6- get grid Panel cell value

I want to get all grid cell value, so I test the first cell with bellow code:我想获得所有网格单元格的值,所以我用下面的代码测试第一个单元格:

var array = [];
var grid = Ext.getCmp('grid');
var selection = grid.getSelectionModel().getSelection()[0];
console.log(array.push(selection)); //it returns 1

however然而

var grid = Ext.getCmp('grid');
var selection = grid.getSelectionModel().getSelection()[0];
console.log(selection);//returns undefined

any suggestions?有什么建议? thanks谢谢

To achieve this first you need to access all the columns of row and then respective cell of the columns.要首先实现这一点,您需要访问行的所有列,然后访问列的相应单元格。 And after you can get all the values of respective cell.然后您可以获得各个单元格的所有值。

You can get this by following code.您可以通过以下代码获取此信息。

select: function(selModel, record, index, options){
                var ColLength = this.columns.length;
                for(var i=0; i<ColLength; i++){
                     var colName = this.getHeaderContainer().getHeaderAtIndex(i+1).dataIndex;
                    cellvalue = record.data[colName];
                    alert(cellvalue);
                }

            }

I made a fiddler for you where you check your complete flow.我为您制作了一个小提琴手,您可以在其中检查完整的流程。 Fiddle小提琴

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

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