0

重複の可能性:
ExtJS4 のグリッド パネルの色の凡例

グリッド内の各セルは、いくつかの基準に基づいて、使用可能な 8 色から任意の色を取得できるという要件があります。これを実装するために、列で「レンダラー」関数を使用し、メタ プロパティの tdCls を css クラスに設定しましたが、機能しません。誰かがこれを解決するのを手伝ってくれますか?

以下のサンプルコードを見つけてください。

/** グリッド パネルを含むビュー クラス*/

Ext.define('xxx.xxx.TestView', {
extend:'Ext.grid.Panel',

  columns:[{
    header:'A', 
    dataIndex:'a', 
    flex:1,
    //rendering function here
    renderer:function(value, metaData, record, rowIndex, colIndex, store) {       
       var cssClass = 'norepl';
       if(value != null && value != ' ') {
             var t = record.get('xxx');
             t = (t.substr(2,t.indexOf('-')-2))%8;
             cssClass = "replgrp"+t;
       }
       metaData.tdCls += cssClass; //attaching css property to tdCls of meta
       return value;
     }   
  }    
});

/** カラーリング用に 8 つの CSS クラスが利用可能*/

.replgrp0 .x-grid-cell {
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);
}


.replgrp1 .x-grid-cell {
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);
}


.replgrp2 .x-grid-cell {
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);
}


.replgrp3 .x-grid-cell {
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);
}


.replgrp4 .x-grid-cell {
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);
}


.replgrp5 .x-grid-cell {
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);
}


.replgrp6 .x-grid-cell {
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);
}


.replgrp7 .x-grid-cell {
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);
}


.norepl .x-grid-cell {
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);
}

よろしくお願いします、ナリ

4

1 に答える 1

0

私は次のようなことをしたことを覚えているようです

 renderer:function(value, metaData, record, rowIndex, colIndex, store){
 if(value != null && value != ' ') {
         var t = record.get('xxx');
         t = (t.substr(2,t.indexOf('-')-2))%8;
         cssClass = "replgrp"+t;
         value="<div class="+cssClass+">"+value+"</div>
   }
  return value;

ただし、これはおそらく間違った方法です:)

于 2012-08-01T20:10:04.940 に答える