1. #1
    Sencha User
    Join Date
    May 2012
    Location
    Ukraine
    Posts
    23
    Vote Rating
    0
    ralfius is on a distinguished road

      0  

    Default 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.
    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'
            }
        ]
    });
    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:
    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

  2. #2
    Sencha - Support Team scottmartin's Avatar
    Join Date
    Jul 2010
    Location
    Houston, Tx
    Posts
    9,154
    Vote Rating
    475
    scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future

      1  

    Default


    See if this will help:

    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()
        });
    });
    ‚Äč
    Scott.

  3. #3
    Sencha User
    Join Date
    May 2012
    Location
    Ukraine
    Posts
    23
    Vote Rating
    0
    ralfius is on a distinguished road

      0  

    Default


    Thanks a lot! I helped.

Thread Participants: 1

Tags for this Thread