PDA

View Full Version : Get Selected Row from a Editor Grid



Ourysso
26 Oct 2010, 4:40 AM
I'm trying to get the selected row from a editor grid.
the selModel of the grid is
sm: new Ext.grid.RowSelectionModel({singleSelect:true})and in a button I need to get the id of the selected Row.
I'm trying this code:
var linha = Ext.getCmp('grid_usuarios').getSelectionModel().getSelected(); How I get the selected row when Click in a button like this:


var botao_delete = {
text: decode_utf8('Excluir Usuário'),
iconCls: 'deleta_user-icon',
handler : function(){
var linha = Ext.getCmp('grid_usuarios').getSelectionModel().getSelected();
//console.log(linha.toSource());
//Ext.Msg.alert('teste', linha.toSource());
}
};
Thanks for the help.

raj_plays
26 Oct 2010, 5:20 AM
var linha = Ext.getCmp('grid_usuarios').getSelectionModel().getSelected();

linha will hold the selected Record.
To get its id, say linha.id.

Ourysso
26 Oct 2010, 5:27 AM
var linha = Ext.getCmp('grid_usuarios').getSelectionModel().getSelected();

linha will hold the selected Record.
To get its id, say linha.id.

I'm trying to get the number of the row, not the Id of the row.
Do you know how I do it?

httpdotcom
26 Oct 2010, 5:39 AM
What do you mean by the number of the row? Some internal value in the columnModel? a numberColumn field?
Since you didn't provide to much in the way of code, it is difficult for forum members to deduce what exactly it is that you are asking for (like what toSource() actually is supposed to do, or how you are defining your grid, column model and record type).

raj_plays
26 Oct 2010, 5:40 AM
store.indexOf(linha)