bootstraptable删除当前行

 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插件

猜你喜欢

转载自blog.csdn.net/LLL_liuhui/article/details/82978187