<script type="text/javascript">
<!-- 方法定义 -->
function addFunctionToTable(value, row, index) {
return [
'<button id="preview" type="button" class="btn btn-default">预览</button>'
].join('');
}
<!-- 操作事件 -->
window.operateEvents = {
'click #preview': function (e, value, row, index) {
alert(row.naspath);
}
};
<!-- 关键代码 -->
$('#table').bootstrapTable({
。。。
columns: [{
checkbox: true
}, {
field: 'id',
title: '编号',
}, {
field: 'name',
title: '名称',
}, {
field: 'operate',
title: '操作',
events: operateEvents,//给按钮注册事件
formatter: addFunctionToTable//表格中增加按钮
}]
</script>
le.li
浙公网安备 33010602011771号