如何使用 ext-js 为网格中的特定列添加背景色

问题描述 投票:0回答:1

我正在尝试为网格表中的 2 列添加背景颜色,我该怎么做? 有什么我可以配置的属性吗?

这里我创建了 2 个表并附加到一个。

请在下面找到我的代码-


var ALIASGRID = new Ext.grid.EditorGridPanel({
                store : ALIASGRIDStore,
                stripeRows : true,
                hideHeaders : true,
                id : "ALIASGRID",
                region : 'center',
                clicksToEdit : 1,
                autoHeight : true,
                viewConfig : {
                    markDirty : false
                },
                columnLines : true,
                columns : [ {
                    id : 'Test',
                    header : 'Test',
                    dataIndex : 'Test',
                    width : 30,
                    editor: {
                    xtype: 'textfield',
         

           triggers: {
                        search: {
                            cls: 'x-fa fa-search',
                            handler: function (field, trigger, eOpts) {}
                                }
                            }
                        },
                    renderer : renderTooltipAndId
                }],
                listeners : {
                    beforeedit : function(grid) {
                        if (!attributeMgrEnabled) {
                            return false;
                        }
                        // console.log(grid);
                    }
                }
            });
            
var ALIASFOOTER = new Ext.grid.EditorGridPanel({
                enableHdMenu : false,
                id : 'ALIASFOOTER',
                height : 19,
                store : ALIASFOOTERStore,
                columns : [ {
                    id : 'Test',
                    header : 'Testing.',
                    resizable : false,
                    width : 30
                }]});           
                
                
// Table that shows empty rows & a footer
            var layoutTable1 = new Ext.Panel({
                width : 470,
                items : [ ALIASGRID, ALIASFOOTER ],
                renderTo : 'AliasTable'
            });

我尝试使用 bodyStyle: 'background-color: #ff0000;财产,但没有用。

javascript node.js extjs
1个回答
0
投票

Use可以在列上使用自定义

renderer
并使用
metadData.tdStyle
指定样式:

columns: [{
    text: 'Name',
    dataIndex: 'name',
    renderer: function (value, metaData) {
        metaData.tdStyle = 'background-color: red;';
        return value;
    },
}],
© www.soinside.com 2019 - 2024. All rights reserved.