PDA

View Full Version : ExtJS 4.2.1 grid.reconfigure() looses selModel config in view



mwmayer4
6 Sep 2013, 8:09 AM
I've seen numerous posts about the reconfigure method loosing the checkboxmodel on reconfigure method. It appears that this was a bug and has been since fixed. However, it does not appear to be working for me.

I have a MVC app with a view definition that contains a selModel config. In a controller I have a function that reconfigures the grid passing both a store and column. The grid does reconfigure properly with the new store definition and column definition but there is no checkbox in the first column of the grid. Either there is a step I'm missing or maybe this still does not work... the selModel just goes poof... Is there something else I need to do to get the selModel back into the grid?

My view and controller code:



Ext.define('ImageInquiry.view.IndexGrid', {
extend: 'Ext.grid.Panel',
alias: 'widget.indexgrid',


initComponent: function() {
var me = this;
Ext.apply(me, {
store: 'Rvabreps',
frame: true,
forceFit: true,
autoScroll: true,
stripeRows: true,
viewConfig: {
loadingText: 'Getting Indexes...',
deferEmptyText: true,
emptyText: '*** No matching indexes found for search criteria ***'
},


selModel: {
xtype: 'checkboxmodel',
mode: 'MULTI',
ignoreRightMouseSelection: true,
checkOnly: true,
injectCheckbox: 0,
showHeaderCheckbox: true
},


tbar: me.buildTbar(),
bbar: me.buildBbar(),
columns: me.buildColumns(),
menu: me.buildMenu()
});


me.callParent(arguments);
},


buildColumns: function() {
return [{}];
},


buildTbar: function() {
return [{
xtype: 'tbtext',
text: 'Ready to Search'
}];
},

buildBbar: function(){
return [{
xtype: 'tbtext',
text: 'Total matching indexes: ',
itemId: 'grid-count'
}];

},


buildMenu: function() {
return Ext.create('Ext.menu.Menu',{
items: [{
text: 'Show Notes',
icon: '/internet/rvi/images/comment.png',
itemId: 'menu-shownotes'
}, {
text: 'Email Image',
icon: '/internet/rvi/images/email.png',
itemId: 'menu-emailimage'
}, {
text: 'Fax Image',
icon: '/internet/rvi/images/email.png',
itemId: 'menu-faximage'
}, {
text: 'Index Details',
icon: '/internet/rvi/images/zoom.png',
itemId: 'menu-indexdetails'
}]
});
}
});


************controller code function************
Ext.define('ImageInquiry.controller.buildGrid', {
extend: 'Ext.app.Controller',

refs: [{
ref: 'IndexGrid',
selector: 'indexgrid'
}],


onBuildGrid: function() {


var store = this.getStore('Keys');
var grid = this.getIndexGrid();
var rvabrep = this.getStore('Rvabreps');

var columnModel = [];
var fields = [];

for (i = 0; i < store.data.items.length; i++) {
dataIndex = store.data.items[i].data.IDX;
text = store.data.items[i].data.IDXDESC;

if(dataIndex === 'SYSTRAN'){
hidden = 'true';
}else{
hidden = 'false';
}

columnModel.push({
text: text,
dataIndex: dataIndex,
hidden: (hidden === 'true') ? true : false
});
fields.push({
name: dataIndex
});
}

rvabrep.model.setFields(fields);
grid.reconfigure(rvabrep, columnModel);
}
});

mwmayer4
7 Sep 2013, 11:25 AM
Sometimes you just want to break something!! So i figured it out. Always something so simple..
changed config to:

selModel: {
checkOnly: true,
injectCheckbox: 0,
ignoreRightMouseSelection: true,
showHeaderCheckbox: true
},
//and added
selType: 'checkboxmodel'

//unbuhleeeeeevable!

super.rotus
8 Apr 2014, 3:15 PM
tx having the same problem, you solved it :D