bootstraptable刪除當前行
阿新 • • 發佈:2018-11-12
1、columns部分
{
field: 'del',
title: '刪除',
width: 100,
align: 'center',
valign: 'middle',
events:delEvents,
formatter:delFunction
}
2、刪除按鈕
function delFunction(value,row,index){ return [ '<button type="button" class="btn btn-primary" id="del_btn">刪除</button>' ].join(''); }
3、刪除事件
//刪除事件 window.delEvents ={ "click #del_btn":function(e,value,row,index) { console.log(row); bootbox.confirm({ size: "small", message: "您確定刪除"+row.no+"行嗎?", buttons: { confirm: { label: '是', className: 'btn-success' }, cancel: { label: '否', className: 'btn-danger' } }, callback: function(result) { if(result) { $.ajax({ method:"post", url:'/list?datatype=jsonp', data:{ no:row.no, }, dataType : "jsonp", async:true, success:function (res) { $("#tab").bootstrapTable('refresh'); } }); } } }); } }
注意引入相關css/js
bootbox是bootbox.min.js外掛