2013-07-26 36 views
6

如何用文本創建ExtJs 4網格動作列? 這是我的代碼用文字創建Extjs 4網格動作列?

{ 
    xtype : 'actioncolumn', 
    text : lang('publish'), 
    width : 100, 
    tdCls: 'x-publish-cell', 
    items : [{ 
     getClass : function(v, meta, rec) { 
      if (rec.get('isPublished') == true) { 
       //this.items[0].tooltip = 'Test'; 
       return 'y'; 
      } else { 
       return 'n'; 
      } 
     } 
    } 

如何用文字創造ExtJS的4格操作列?

+0

你想讓它成爲沒有圖像或圖像的文字嗎? – Reimius

+0

文字與圖像。像[圖片] [這裏的文字] – user2622564

回答

13

您可以使用該列的renderer。訣竅是,分機專門隱藏CSS規則隱藏動作列的內容:

.x-grid-cell-inner-action-col { 
    line-height: 0; 
    font-size: 0; 
} 

所以,你將不得不以補償。

例子:

{ 
    xtype:'actioncolumn', 
    renderer: function() { 
     return 
      '<div style="float:right; font-size: 13px; line-height: 1em;">' 
       + 'Hey!' 
      + '</div>' 
    }, 
    items: [ 
     // ... 
    ] 
} 

在這裏,我用內嵌式的,而是一個自定義的CSS類可能會更好。

現在,您可以在列中添加一些文本。如果您想要實現的是在該列中爲每個操作項目添加一些文字,則必須覆蓋Ext.grid.column.Action#defaultRenderer

+0

它的工作原理。謝謝 ! – user2622564

+0

thanx隊友我正在尋找同樣的問題,歡呼聲 – kavinder