ExtJs4 在 Statuscode 上更改字段颜色

ExtJs4 Change Field color on Statuscode

你好,我正在与 ExtJs 斗争,我正在尝试更改单元格名称为 'statuscode' 的 ExtJs 网格中的颜色,如果状态码为 1,则单元格必须将颜色更改为绿色!有人有想法吗?谢谢

Ext.define('Shopware.apps.ArticleUpdateLog.model.ArticleUpdateLog', {
    extend: 'Shopware.data.Model',
    configure: function () {
        return { 
                controller: 'ArticleUpdateLog'
        };
    },
    fields: [
        { name : 'id', type: 'int', useNull: true },
        { name : 'importTimestamp', type: 'string' },
         { name : 'statuscode', type: 'string', useNull: true },
        { name : 'status', type: 'string', useNull: true }

    ]
});

网格的每一列都有一个渲染器配置 render: function(value, meta, record)。因此,您可以使用 record.get('status') 检查当前值并向给定单元格添加 css 样式。

http://docs.sencha.com/extjs/4.2.2/#!/api/Ext.grid.column.Column-cfg-renderer

另请查看元参数,它授予对您想要的特定单元格进行样式设置的权限。