如何用文本创建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网格操作列?
您可以使用列的renderer
。诀窍是Ext专门隐藏了一个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
。