PDA

View Full Version : How to get id of record for selected row in GridPanel?



bbxx
18 Oct 2009, 5:10 PM
How do I get the id of record for selected row in a GridPanel? I've been looking through the documentation but still can't figure it out. Should be simple I would imagine?

bbxx
18 Oct 2009, 5:23 PM
Not sure about the answer to my question, but I found a work around:



sm: new Ext.grid.RowSelectionModel(
{singleSelect: true,
listeners:
{
'rowselect': function(sm, row, rec)
{
alert(rec.get('ID'));
}
}
}),

elishnevsky
18 Oct 2009, 5:30 PM
You have to go through selection model (by default it's RowSelectionModel)


// to get the selected record
var selectedRecord = yourgrid.getSelectionModel().getSelected();

// to get value of a field in the record
var val = selectedRecord.get('field_name_here');