2009-08-04 8 views

答えて

5

カスタムformatter関数を使用すると、任意のHTMLをセルに配置できます。列の定義は次のようになります。

var myColumnSet = [ 
    { 
     key: 'active_employee', 
     label: 'Active', 
     formatter: function(el, oRecord, oColumn, oData) { 
      // el is the HTMLElement of the current cell 
      // oRecord gives you access to other fields from the 
      // DataSource, e.g.: oRecord.getData('full_name') 
      // oData is the value of the current field (active_employee) 

      if (oData) { 
       el.innerHTML = '<img src="/images/active.png">'; 
      } else { 
       el.innerHTML = '<img src="/images/not-active.png">'; 
      } 
     } 
    }, 
    // other Columns.... 
]; 

Custom Cell Formatting exampleも参照してください。

+0

同じ問題が発生していますが、上記のコードは機能しません。別の方法がありますか? – codeBarer

+0

申し訳ありませんが、私は数年前にYUIで働いていません。これは変更されている可能性があります。うまくいけば、誰かがそれについてより多くの最新情報をコメントできます。 – Nate

+1

YUI3に関する情報が見つかりました。私がしなければならなかったのは、allowHTMLという特別なオブジェクトを追加することでした。 – codeBarer