以下两个方法,要在 列初始化前
function addFunctionAlty(value, row, index) {
if (value != undefined){
return [
value,
" ",
'<button id="bind" type="button" class="btn">详情</button>',
].join('');
}
}
window.operateEvents = {
'click #bind': function (e, value, row, index) {
alert(value);
}
};
//列中添加
return [
{title: '成本总额',
field: 'TOTAL_COST',
events: operateEvents, //给按钮注册事件
formatter: addFunctionAlty //表格中增加按钮
},
];
效果