PDA

View Full Version : Ext JS 4.2: Checkbox model selection issue



tharahan-citi
21 Jun 2013, 2:20 PM
I recently switched to 4.2.1 from 4.1.3. I have a grid with check box model. When user select or deselect a record, app selects (or deselects) all relevant records based common record attribute value. This was working perfectly,but, after migration, stop works. When I looked at on FB, I can see two events fired (select and deselect)

var exSelectionModel = Ext.create('Ext.selection.CheckboxModel', {
checkOnly: true,

viewConfig: {
listeners: {
beforecellmousedown: function(view, cell, cellIdx, record, row, rowIdx, eOpts){

}
}
},
listeners: {

selectionchange: function(sm, selections) {

console.log(selections);
},


select: function( sm, record, index, eOpts ){

var blockId = record.data.blockId;

var blockRecords = sm.getStore().queryBy(function(rec){
return rec.data.blockId == blockId;


var records = new Array();
Ext.each(blockRecords.items, function(bRec){
records.push(bRec);
});

sm.select(records,true,true);


},
deselect: function( sm, record, index, eOpts ){
var blockId = record.data.blockId;


var blockRecords = sm.getStore().queryBy(function(rec){
return rec.data.blockId == blockId;
});

var records = new Array();
Ext.each(blockRecords.items, function(bRec){
records.push(bRec);
});

sm.deselect(records,true,true);
}
}
});

Is anything changed in 4.2.1

slemmon
24 Jun 2013, 1:05 PM
The only thing I can think of that changed was that there was a bug that was fixed where in 4.1.3 the selection mode was SINGLE, but the API specified MULTI as the default - so in 4.2.1 the mode is MULTI by default.

I'm not yet sure what issue you're seeing. The below test case responded the same in 4.1.3 and 4.2.1. Can you elaborate on the issue you're working with?



Ext.create('Ext.data.Store', {
storeId:'simpsonsStore',
fields:['name', 'email', 'phone'],
data:{'items':[
{ 'name': 'Lisa', "email":"lisa@simpsons.com", "phone":"555-111-1224" },
{ 'name': 'Bart', "email":"bart@simpsons.com", "phone":"555-222-1234" },
{ 'name': 'Homer', "email":"home@simpsons.com", "phone":"555-222-1244" },
{ 'name': 'Marge', "email":"marge@simpsons.com", "phone":"555-222-1254" }
]},
proxy: {
type: 'memory',
reader: {
type: 'json',
root: 'items'
}
}
});


Ext.create('Ext.grid.Panel', {
title: 'Simpsons',
store: Ext.data.StoreManager.lookup('simpsonsStore'),
columns: [
{ text: 'Name', dataIndex: 'name' },
{ text: 'Email', dataIndex: 'email', flex: 1 },
{ text: 'Phone', dataIndex: 'phone' }
],
height: 200,
width: 400,
selModel: {
selType: 'checkboxmodel',
mode: 'SINGLE',
checkOnly: true
},
renderTo: Ext.getBody(),
listeners: {
selectionchange: function () {
console.log('selectionchange fired');
},
select: function () {
console.log('select fired');
},
deselect: function () {
console.log('deselect fired');
}
}
});

durga27
17 Apr 2017, 1:09 AM
hi ,
Am facing similar kind of issue actuallly in my case i am using couple of checkboxes in the grid for approving and deletion of items.
So when am trying to get the selected checkbox values it is giving null.
My Code for Selection Model:
var selModel = Ext.create('Ext.selection.CheckboxModel', {
columns: [
{xtype : 'checkcolumn', text : 'Approve', dataIndex : 'Approve'},
{xtype : 'checkcolumn', text : 'Delete', dataIndex : 'Delete'},
],
checkOnly: true,
mode: 'multi',
enableKeyNav: false,
});

Thanks in Advance.