PDA

View Full Version : [SOLVED] id value of a selected row in grid



lpastor
29 Aug 2009, 12:22 PM
Hello,

I try to get the value of the id field in a grid.
I tried several solutions in talks on the forum, but none works.

Here is my code :




var userColumnsGrid = [
{header: "ID", id:'id', width: 40, sortable: true, dataIndex: 'id_projet'},
....
....


var userGrid = new gridlp({
region: 'center',
store: store,
plugins: filters,
columns : userColumnsGrid,
view: new Ext.grid.GroupingView({
forceFit:true,
groupTextTpl: '{text} ({[values.rs.length]} {[values.rs.length > 1 ? "Eléments" : "Elément"]})'
}),
listeners: {
rowclick: function(g, index, ev) {
var rec = g.store.getAt(index);
userForm.loadRecord(rec);
Ext.getCmp('slider_avancement').setValue(Ext.getCmp('avancement_projet').getValue());

//var id = g.store.getAt(index).data.id; //Don't work
var id = Ext.getCmp('userGrid').getSelectionModel().getSelected().data.id; //Don't work

Ext.MessageBox.alert('SELECTION',id);

//var s= g.getSelectionModel();
//var r = s.getSelected();
//alert(r.get('id')); // Don't work

//var cell = userGrid.getSelectionModel().getSelectedCell();
//var record = userGrid.getDataSource().getAt(cell[0]);
//alert(record.get('tcol-' + cell[1])); // Don't work

}
}
});

lpastor
29 Aug 2009, 1:34 PM
I found, my problem that I used the id name (id) instead of use the data store name (id_projet)