本文介绍了ExtJS 4 - 如何为网格的列添加背景颜色?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个网格,我需要在其中为各个列提供不同的背景颜色.

I have a grid in which I need to provide different background colors to various columns.

这些列颜色也不应该被 mouse-over 颜色覆盖.

These column colors should also not be overwritten by the mouse-over color.

我尝试过使用 clstdCls 但没有成功.

I have tried using cls and tdCls but no luck.

任何人都可以指导如何实现这一目标吗?

Could anyone guide at how this could be achieved?

提前致谢.

推荐答案

NetEmp 就在这里,你想要一个渲染器并且你想使用直接的 'style' 方法,或者我在下面使用以下方法:

NetEmp is right here, you want a renderer and you want to use the direct 'style' method or I did it below using the following:

function greyRenderer(lpValue, opMeta, opData)
{

    if (opData.data["Condition"] == 0) {
        opMeta.attr = "style='color: #aaa';";
    }

    lpValue = Ext.util.Format.htmlEncode(lpValue);
    return lpValue;
}

请注意,这里我检查特定字段中的行上的值,然后将颜色应用于前景文本和 html 编码输出,您显然可以根据您的特定要求进行切换.

Note here I check the value on the row in a particular field and then apply the colour to the foreground text and html encode the output, you can obviously just switch things to your specific requirements.

这篇关于ExtJS 4 - 如何为网格的列添加背景颜色?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-18 11:31
查看更多