问题描述
我有一个网格,我需要在其中为各个列提供不同的背景颜色.
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.
我尝试过使用 cls
和 tdCls
但没有成功.
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 - 如何为网格的列添加背景颜色?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!