代码之家  ›  专栏  ›  技术社区  ›  azer-p

组合框在网格编辑器中保持可见

  •  0
  • azer-p  · 技术社区  · 8 年前

    1 回复  |  直到 8 年前
        1
  •  1
  •   Narendra Jadhav    8 年前

    如何使其在网格中永久可见?

    5.x 或更高,您可以使用 widgetcolumn

    我创建了一个 sencha fiddle 演示希望这将帮助您解决问题或达到您的要求。

    Ext.create('Ext.data.Store', {
            storeId: 'simpsonsStore',
            fields: ['name', 'email', 'phone', {
                name: 'checked',
                defaultValue: 'AL'
            }],
            data: [{
                name: 'Lisa',
                email: 'lisa@simpsons.com',
                phone: '555-111-1224'
            }, {
                name: 'Bart',
                email: 'bart@simpsons.com',
                phone: '555-222-1234'
            }, {
                name: 'Homer',
                email: 'homer@simpsons.com',
                phone: '555-222-1244'
            }, {
                name: 'Marge',
                email: 'marge@simpsons.com',
                phone: '555-222-1254'
            }]
        }),
        states = Ext.create('Ext.data.Store', {
            fields: ['abbr', 'name'],
            data: [{
                "abbr": "AL",
                "name": "Alabama"
            }, {
                "abbr": "AK",
                "name": "Alaska"
            }, {
                "abbr": "AZ",
                "name": "Arizona"
            }]
        });
    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'
        }, {
            text: 'State',
            width: 150,
            xtype: 'widgetcolumn',
            dataIndex: 'checked',
            widget: {
                xtype: 'combobox',
                flex: 1,
                emptyText: 'Select State',
                queryMode: 'local',
                displayField: 'name',
                valueField: 'abbr',
                store: states,
                listeners: {
                    select: function (combo, record) {
                        Ext.Msg.alert('Success', 'Good you have selected <b>' + record.get('name') + '</b>')
    
                        var grid = combo.up('grid'),
                            index = grid.getView().indexOf(combo.el.up('table')),
                            record = grid.getStore().getAt(index);
    
                        console.log(record.getData());
                    }
                }
            }
        }],
        height: 200,
        width: 400,
        renderTo: Ext.getBody()
    });
    
    推荐文章