PDA

View Full Version : Need assistance prechecking Checkbox on selection model



dlbjr
13 Oct 2009, 5:33 AM
I would appreciate any assistance:

I need help preselecting a checkbox in the Selection Model on a grid based on a value in the record. Field name is ingroup. The value is '1' = on and '0' = off. Here is my code fragment:




var ds_cals = new Ext.data.JsonStore({
url: Config.dataURL,
root: 'data',
fields: [
{ name: 'cal_id', type: 'string'},
{ name: 'cal_desc', type: 'string', convert: function(v){return unescape(v);} },
{ name: 'cal_type', type: 'string', convert: function(v){return unescape(v);} },
{ name: 'owner', type: 'string', convert: function(v){return unescape(v);} },
{ name: 'ingroup', type: 'string' }
]
});

var smCheckBox = new Ext.grid.CheckboxSelectionModel({
checkOnly: true,
header: '',
listeners: {
rowselect : function(sm, rowIndex, record) {


},
rowdeselect: function(sm, rowIndex, record) {


}
}
});


var g = new Ext.grid.GridPanel({
loadMask: { msg: Config.load_mask, store: ds_cals },
viewConfig: { emptyText: Config.grid_no_data },
title: '',
store: ds_cals,
height: 310,
width: 600,
stripeRows: true,
autoScroll: true,
clicksToEdit: 1,
sm: smCheckBox,
cm: new Ext.grid.ColumnModel([new Ext.grid.RowNumberer(),
smCheckBox,
{
header: 'id',
dataIndex: 'cal_id',
hideable: true,
sortable: true,
hidden: true,
}...

MiamiCoder
13 Oct 2009, 5:00 PM
You could try using the rowinserted event of the grid's view to check the flag and store the indexes of the records that are in the group. Later you could call selectRows() on the selection model, passing the array of indexes.