javascript - 列上带有单选按钮的 ExtJS GridPanel

标签 javascript extjs radio-button extjs6 gridpanel

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

                  {
                        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'
                                    },
                               }

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

最佳答案

And it doesn't work. So i am here to ask any sugestions

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

我创建了一个 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()
});

关于javascript - 列上带有单选按钮的 ExtJS GridPanel,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46567118/

相关文章:

javascript - 从键盘或小键盘识别 2 键

c# - 首先运行 javascript,成功后运行后面的代码

javascript - extjs 应用程序在 web2py 中显示空白页面

javascript - Ext.Button 上没有命名的方法

extjs - 在 extjs 中删除行后重新加载网格选择

javascript - d3.js 根据过滤器更改节点及其传出和传入链接的不透明度

javascript - 如何将表单内容从 JavaScript 转换为 PHP?

java - 如何交换两个按钮

javascript - 如何根据在rails简单表单中选中的单选按钮渲染输入表单

javascript - 从 helloworld 应用程序中删除 nativescript listview 项目