简体   繁体   中英

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

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