PDA

View Full Version : Ext.grid.CheckboxSelectionModel :: Example needed.



vinayrajaram
29 Oct 2012, 11:13 PM
I have grid with checkbox selction model when I select the checkbox the selected row details should be captured.

Can anyone help me how to get the selected row details in grid, sample code needed

tsuryap
30 Oct 2012, 1:25 AM
var checkboxselection = new Ext.grid.CheckboxSelectionModel({ singleSelect: true, listeners: { 'selectionchange' : function(selectionModel, selectedRecords, options) {
for(var i=0;i<selectedRecords.length;i++)
alert(selectedRecords[i]); } } });
try this code may be it will work and please add this listeners to your extisting checkbox selectin model

vinayrajaram
30 Oct 2012, 2:06 AM
I want complete code with and checkbox selection model finally when i select the checkbox retreive the selected row values from it.

tsuryap
30 Oct 2012, 6:07 AM
Ext.onReady(function(){

var sm = new Ext.selection.CheckboxModel(
{
singleSelect: true,
listeners: {
select:function( t, record, index, eOpts ) {
alert(record.data['company']+", "+record.data['price']+", "+record.data['change']);
}
}
}
);

var store = Ext.create('Ext.data.ArrayStore', {
fields: ['company', 'price', 'change'],
data: [
['3m Co', 71.72, 0.02],
['Alcoa Inc', 29.01, 0.42],
['Altria Group Inc', 83.81, 0.28],
['American Express Company', 52.55, 0.01],
['American International Group, Inc.', 64.13, 0.31],
['AT&T Inc.', 31.61, -0.48]
]
});

var grid = Ext.create('Ext.grid.Panel', {
title: 'Array Grid',
store: store,
selModel: sm,
columns: [

{text: 'Company', flex: 1, dataIndex: 'company'},
{text: 'Price', width: 75, dataIndex: 'price'},
{text: 'Change', width: 75, dataIndex: 'change'}
],
height: 200,
width: 400,
renderTo: Ext.getBody()
});


});