Results 1 to 3 of 3

Thread: Problem with multiple grids with CheckboxModel usage

  1. #1
    Sencha User
    Join Date
    May 2012
    Location
    Ukraine
    Posts
    23
    Vote Rating
    0
      0  

    Default 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,389
    Vote Rating
    498
      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
      0  

    Default

    Thanks a lot! I helped.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •