且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

ExtJS 4 - 如何为网格的列添加背景颜色?

更新时间:2023-11-26 13:13:46

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.