Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get selected row column value extjs grid

I have a users grid. To delete one, select your row and click a button "delete". But, this not work. My code is:

var row = userGrid.getSelectionModel().getSelection();
console.log(row.get('dni'))

Firefox says:

TypeError: row.get is not a function

Any idea ?.

like image 573
ramiromd Avatar asked Jan 04 '13 21:01

ramiromd


2 Answers

It is good practice to always check hasSelection() like -

if (userGrid.getSelectionModel().hasSelection()) {
   var row = userGrid.getSelectionModel().getSelection()[0];
   console.log(row.get('dni'))
}
like image 173
Avinash T. Avatar answered Oct 07 '22 07:10

Avinash T.


perhaps because

getSelection( ) : Ext.data.Model[]

Returns an array of the currently selected records.

http://docs.sencha.com/ext-js/4-1/#!/api/Ext.selection.Model-method-getSelection

like image 21
dbrin Avatar answered Oct 07 '22 07:10

dbrin