【发布时间】:2011-02-16 10:47:26
【问题描述】:
在 ExtJS 网格中我有一列,当单元格的内容为某个值时,应该显示一个 按钮。
我定义了包含这样按钮的列,它调用渲染函数:
{
header: 'Payment Type',
width: 120,
sortable: true,
renderer: renderPaymentType,
dataIndex: 'paymentType'
}]
在渲染函数中,我返回文本或按钮本身:
function renderPaymentType(val) {
if(val!='creditInform') {
return val;
} else {
return new Ext.Button({
text: val,
width: 50,
handler: function() {
alert('pressed');
}
});
}
}
这基本上是可行的,只是按钮显示为文本[object Object]:
我必须怎样做才能使按钮显示为按钮而不是文本?
附录
添加.getEl():
function renderPaymentType(val) {
if(val!='creditInform') {
return val;
} else {
return new Ext.Button({
text: val,
width: 50,
handler: function() {
alert('pressed');
}
}).getEl();
}
}
产生一个空白:
添加.getEl().parentNode.innerHTML:
function renderPaymentType(val) {
if(val!='creditInform') {
return val;
} else {
return new Ext.Button({
text: val,
width: 50,
handler: function() {
alert('pressed');
}
}).getEl().parentNode.innerHTML;
}
}
尽管在 Firebug 中的其余代码会导致某种渲染问题,但奇怪的是我没有收到任何错误:
【问题讨论】:
标签: javascript extjs grid