css - ExtJS4 中网格面板的颜色图例

标签 css extjs grid extjs4

我有一个要求,即网格中的每个单元格都可以根据某些标准从可用的 8 种颜色中选择任何颜色。之后,我需要在网格面板下方显示这 8 种颜色的颜色图例及其标签名称。如果 ExtJS4 具有任何此类网格功能或关于如何解决此问题的任何想法,有人可以建议我吗?

/** CSS 示例 */

.r1 .x-grid-cell-inner {
background-color: #f0f6ff;
color: #09d6ff;
border-left: 1px dotted rgba(2, 3, 3, 0.27);
border-right: 1px dotted rgba(2, 3, 3, 0.27);
}


.r2 .x-grid-cell-inner {
background-color: rgba(255, 183, 189, 0.22);
color: #900;
border-left: 1px dotted rgba(2, 3, 3, 0.27);
border-right: 1px dotted rgba(2, 3, 3, 0.27);
}


.r3 .x-grid-cell-inner {
background-color: #e2ffe2;
color: #090;
border-left: 1px dotted rgba(2, 3, 3, 0.27);
border-right: 1px dotted rgba(2, 3, 3, 0.27);
}


.r4 .x-grid-cell-inner {
background-color: rgba(255, 233, 228, 0.12);
color: #99890e;
border-left: 1px dotted rgba(2, 3, 3, 0.27);
border-right: 1px dotted rgba(2, 3, 3, 0.27);
}


.r5 .x-grid-cell-inner {
background-color: rgba(186, 242, 250, 0.10);
color: #1a4f99;
border-left: 1px dotted rgba(2, 3, 3, 0.27);
border-right: 1px dotted rgba(2, 3, 3, 0.27);
}


.r6 .x-grid-cell-inner {
background-color: rgba(255, 242, 239, 0.23);
color: #ff7f00;
border-left: 1px dotted rgba(2, 3, 3, 0.27);
border-right: 1px dotted rgba(2, 3, 3, 0.27);
}


.r7 .x-grid-cell-inner {
background-color: rgba(228, 224, 255, 0.7);
color: rgba(29, 7, 255, 0.60);
border-left: 1px dotted rgba(2, 3, 3, 0.27);
border-right: 1px dotted rgba(2, 3, 3, 0.27);
}


.r8 .x-grid-cell-inner {
background-color: rgba(255, 233, 228, 0.32);
color: rgba(255, 22, 12, 0.65);
border-left: 1px dotted rgba(2, 3, 3, 0.27);
border-right: 1px dotted rgba(2, 3, 3, 0.27);
}


.n1 .x-grid-cell-inner {
background-color: rgb(255, 255, 255);
color: rgb(255, 127, 0);
border-left: 1px dotted rgba(2, 3, 3, 0.27);
border-right: 1px dotted rgba(2, 3, 3, 0.27);
}

最佳答案

我不得不做类似的事情。

我使用列的 renderer 配置根据值将“颜色”类应用于单元格。

在我的例子中,值决定了单元格的颜色。

这是渲染器:

// ... other column configs
renderer: function(value, meta, record) {
    switch(value) {

        case 1 : 
            meta.tdCls = 'orange-cell';
            break;

        case 2 : 
            meta.tdCls = 'light-orange-cell';
            break;

        case 3 : 
            meta.tdCls = 'green-cell';
            break;   
    }

    // I only had a color in my cell without any kind of value
    // so didn't include the following return statement. I added it here
    // just so you would know that you can have it also.
    return value;
}

CSS 类如下所示:

.orange-cell {
    background-color: #ffbb22 !important;
}
.light-orange-cell {
    background-color: #33cc55 !important;
}
.green-cell {
    background-color: #ffeecc !important;
}

这在 ExtJS 4.1.0 上运行良好

关于css - ExtJS4 中网格面板的颜色图例,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11767469/

相关文章:

css - 制作响应面板

javascript - Extjs 4 : Create an iFrame Window

css - CSS 中类似表格的图像网格(但有一个扭曲)

flutter - 如何在Flutter中创建可滚动的网格?

ExtJS:网格 100% 高度

css - 实时 CSS 预览的可能性?

javascript - 获取显示为 block 的元素

css - 疯狂的 div 结构 CSS - 请帮忙

extjs - 使用 extjs Controller

javascript - 工具提示不适用于仪表图