可以使用renderer函数来实现在grid组件中的column中应用Ext.button.Button。

示例代码:

Ext.create('Ext.grid.Panel', {
    title: 'Button Column Demo',
    store: Ext.create('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: 'homer@simpsons.com', phone: '555-222-1244'},
            {name: 'Marge', email: 'marge@simpsons.com', phone: '555-222-1254'}
        ]
    }),
    columns: [
        {text: 'Name', dataIndex: 'name'},
        {text: 'Email', dataIndex: 'email'},
        {
            text: 'Phone',
            dataIndex: 'phone',
            renderer: function (value) {
                return Ext.create('Ext.button.Button', {
                    text: value,
                    handler: function () {
                        alert(value);
                    }
                }).renderToString();
            }
        }
    ],
    height: 200,
    width: 400,
    renderTo: Ext.getBody()
});

在上述代码中,使用了renderer函数来创建一个Ext.button.Button,并将其渲染为HTML字符串,然后返回该字符串作为该列的单元格内容。在该按钮的handler函数中,可以执行用户自定义的操作,例如弹出提示框。

extjs中如何在grid组件中的column中应用ExtbuttonButton

原文地址: https://www.cveoy.top/t/topic/b4RU 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录