PDA

View Full Version : Getting value of gridpanel's cell



maxkliver
9 Jul 2012, 8:15 PM
Hi guys.
I have a gridpanel with some columns. Also i have CheckboxSelectionModel. And i want to get value of cell with name "id" of checked rows.


var sm = new Ext.grid.CheckboxSelectionModel({
//header: '',
//singleSelect : 'true',
listeners: {
selectionchange: function(sm) {
//alert('coucou : ' + sm.getSelected().id);
alert('coucou : ' + sm.selectRow(0));

}
}
});

Columns


var cm = new Ext.grid.ColumnModel({
columns: [sm,{
xtype: 'checkcolumn',
header: '',
dataIndex: 'indoor',
width: 50
},{
header: 'id',
dataIndex: 'kad_id',
width: 70
},{
header: '???????',
dataIndex: 'kad_name',
width: 130,
}]
})

How to do this??

maxkliver
9 Jul 2012, 8:24 PM
Ok im dummy. To get a value of cell with name id needed


var sm = new Ext.grid.CheckboxSelectionModel({

listeners: {
selectionchange: function(sm) {
alert('coucou : ' + sm.getSelected().get("id"));
}
}
});

maxkliver
9 Jul 2012, 8:52 PM
But how to get multiple select?


for(h=0;h<sm.getSelections().length;h++){
alert(sm.getSelections[h].get("kad_id"));
}

Not work.

sword-it
9 Jul 2012, 9:52 PM
And i want to get value of cell with name "id" of checked rows.


Hi!

you may use following for multiple selections.




var selectedRecords=yourGrid.getSelectionModel().getSelection(),
nameCellValues=[];

for(var i=0;i<selectedRecords.length;i++){
nameCellValues.push(selectedRecords[i].get('kad_id'));
}



above, nameCellValues (which is an array) contains your selected row's id cell values.

maxkliver
10 Jul 2012, 12:48 AM
Strange but this code work.


var getS=csm.getSelections();
for(var hh=1;hh<csm.getSelections().length;hh++){
//do something
}