javascript - 向 Ext JS Grid 列添加新属性

标签 javascript extjs sencha-touch extjs6 extjs6-classic

我可以在 Ext JS 中向 gridcolumn 添加新的唯一属性吗?我想在其他地方使用该属性

{
    xtype: 'gridcolumn',
    dataIndex: 'startupPercent',
    sortable: true,
    'property': 'value', // so that i can access it later
    text: 'StartUp%'
}

最佳答案

Can I add a new unique property to gridcolumn

是的,您可以,并且您可以在其他地方使用该属性(property)。

在此FIDDLE ,我创建了一个演示,提供自定义配置并单击标题。我希望这将帮助/指导您实现您的要求。

代码片段

Ext.application({
    name: 'Fiddle',

    launch: function () {
        Ext.create('Ext.grid.Panel', {
            title: 'Demo',
            store: {
                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'
                }]
            },
            columns: [{
                text: 'Name',
                dataIndex: 'name',
                isName: true
            }, {
                text: 'Email',
                dataIndex: 'email',
                flex: 1
            }, {
                text: 'Phone',
                dataIndex: 'phone'
            }],
            height: 200,
            renderTo: Ext.getBody(),
            listeners: {
                headerclick: function (ct, column, e, t, eOpts) {
                    if (column.isName) {
                        console.log(column.isName);
                    }
                }
            }
        });
    }
});

关于javascript - 向 Ext JS Grid 列添加新属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50174647/

相关文章:

javascript - Galleria:显示最后一张图片

extjs - 在面板中心对齐组件 : EXT JS

html - 将 Java Applet 添加到 Sencha Touch 2

javascript - Three.js + OrbitControls - 未捕获的 TypeError : Cannot read property 'addEventListener' of undefined

javascript - 在不破坏 CSS/JS 的情况下将旧的静态页面添加到 Rails 应用程序中

javascript - Extjs 6.0 颜色选择器十六进制字段

javascript - 从 Ext JS 4.2 调用 aspx 时遇到问题

html - 移动网络应用程序的服务器端架构

extjs - 如何销毁 Sencha Touch 中的非事件 View

javascript 意外的 token *