【问题标题】:ExtJS GridPanel with radiobutton on the columns列上带有单选按钮的 ExtJS GridPanel
【发布时间】:2018-03-15 23:31:50
【问题描述】:

所以我有一个通常的网格,有一些列:

                  {
                        xtype          : 'gridpanel',
                        mode           : "MULTI",
                        region         : 'center',
                        title          : "grid",
                        id             : 'datagridResult',  
                        margin         : '10 5 5 5',

                    columns : [
                               {
                                   xtype    : 'gridcolumn',
                                   dataIndex: 'TEST',
                                   flex     : 0.25
                               },   
                               {
                                   xtype    : 'gridcolumn',
                                   dataIndex: 'Test2'
                                   flex     : 2
                               },   
                               //...

我想要的是再添加 3 列单选按钮(每列一个按钮)。我尝试过这样的事情:

                             {
                                   xtype    : 'gridcolumn',
                                   text     : "FOR"
                                   dataIndex: 'for',
                                   flex     : 1,
                                   editor: { 
                                        xtype     : 'radiofield',
                                        name      : 'Regex',
                                        inputValue: 'Checked'
                                    },
                               }

而且它不起作用。所以我在这里问任何建议。

【问题讨论】:

    标签: javascript extjs radio-button extjs6 gridpanel


    【解决方案1】:

    而且它不起作用。所以我在这里问任何建议

    在 ExtJS 中有 xtype :'widgetcolumn'。 一个小部件列配置了一个小部件配置对象,该对象指定一个 xtype 来指示该列的单元格中属于哪种类型的 Widget 或组件。

    我创建了一个Sencha Fiddle 演示。它将显示如何工作。希望这会对你有所帮助。

    Ext.create('Ext.data.Store', {
        storeId: 'simpsonsStore',
        fields: ['name', 'email', 'phone', {
            name: 'checked',
            type: 'boolean',
            defaultValue: true
        }],
        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'
        }]
    });
    
    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: 'Status',
            width: 150,
            xtype: 'widgetcolumn',
            dataIndex: 'checked',
            onWidgetAttach: function (column, widget, record) {
                widget.down(`[inputValue=${record.get('checked')}]`).setValue(true);
            },
            widget: {
                xtype: 'radiogroup',
                items: [{
                    boxLabel: 'Yes',
                    inputValue: true
                }, {
                    boxLabel: 'No',
                    inputValue: false
                }]
            }
        }],
        height: 200,
        width: 400,
        renderTo: Ext.getBody()
    });
    

    【讨论】:

    • 谢谢,正是我想要的
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-04-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多