色彩的传说在ExtJS4网格面板(Color legend for grid panel in Ex

2019-07-30 18:20发布

我有网格中的每个单元可以采取任何颜色出基于某些准则可用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);
}

Answer 1:

我不得不做类似的事情。

我申请一个“色”类细胞基于使用列的值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这是工作的罚款



Answer 2:

添加类似的东西,以网格的定义:

viewConfig: {
  getRowClass: function(record, rowIndex, rowParams, store){
    return record.get("valid") ? "row-valid" : "row-error";
  }
}

见http://docs.sencha.com/ext-js/4-0/#!/api/Ext.view.Table-method-getRowClass了解更多详情。

注意 :这会为各行工作。 你真的需要的细胞通过细胞色素?



文章来源: Color legend for grid panel in ExtJS4