-
30 Jul 2012 5:00 AM #1
Problem with multiple grids with CheckboxModel usage
Problem with multiple grids with CheckboxModel usage
Hey!
Could you please help me with such a problem: I have defined xtype that is simple grid with 2 columns and selModel: Ext.selection.CheckboxModel.
When I am trying to use this xtype several times in one panel there is a problem: instead of creating new CheckboxModel for each usage, each xtype uses the same instance of already created CheckboxModel. This problem is well seen on the screen:Code:Ext.define('MySimpleType', { extend: 'Ext.grid.Panel', alias: 'widget.MySimpleXType', autoScroll: true, store: mySimpleStore, selModel: Ext.create("Ext.selection.CheckboxModel", { checkOnly : true }), border: false, columns: [ { header: 'Code', flex: 1, sortable: true, dataIndex: 'Code' }, { header: 'Name', flex: 1, width: 80, sortable: true, dataIndex: 'Name' } ] });
CheckBoxModels.jpg
Could you please give me some idea of how to fix this. The simplest solution is to create new Ext.selection.CheckboxModel instance for every xtype usage, but it makes code copy-pasted
-
30 Jul 2012 7:31 AM #2
See if this will help:
Scott.Code:Ext.onReady(function () { Ext.define('App.MyStore', { extend: 'Ext.data.Store', fields: ['name', 'email', 'phone'], data: [ { '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" } ] }); Ext.define('App.MyGrid', { extend: 'Ext.grid.Panel', alias: 'widget.mygrid', title: 'Simpsons', width: 500, initComponent: function () { this.store = Ext.create('App.MyStore'); this.selModel = Ext.create("Ext.selection.CheckboxModel", { checkOnly : true }); this.callParent(arguments); }, columns: [ { header: 'Name', dataIndex: 'name' }, { header: 'Email', dataIndex: 'email', flex: 1 }, { header: 'Phone', dataIndex: 'phone' } ] }); Ext.widget('mygrid', { title: 'First Panel', renderTo: Ext.getBody() }); Ext.widget('mygrid', { title: 'Second Panel', margin: '5 0 0 0', renderTo: Ext.getBody() }); });
-
2 Aug 2012 1:04 AM #3


Reply With Quote
