Get selected row column value extjs grid
52,711
Solution 1
It is good practice to always check hasSelection()
like -
if (userGrid.getSelectionModel().hasSelection()) {
var row = userGrid.getSelectionModel().getSelection()[0];
console.log(row.get('dni'))
}
Solution 2
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
Comments
-
ramiromd over 3 years
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 ?.
-
egerardus over 11 years@ramiromd In other words try:
var row = userGrid.getSelectionModel().getSelection()[0];
if you only want the first record selected or this is a single selection grid