遇到bootstraptable无法重新加载的问题,查阅大神的博客,找到了解决方案,记录下,以便查阅。
问题:通过设置查询条件,点击按钮触发bootstrap-table,触发以后无法再次触发
解决方案:在初始化table之前,要将table销毁,否则会保留上次加载的内容
$("#tb_addZph").bootstrapTable('destroy'); // 在初始化table之前,要将table销毁,否则会保留上次加载的内容
$('#tb_addZph').bootstrapTable({
url: '/zph/getZphInfo2Com', //请求后台的URL(*)
method: 'get', //请求方式(*)
//toolbar: '#toolbar_zph', //工具按钮用哪个容器
striped: true, //是否显示行间隔色
cache: false, //是否使用缓存,默认为true,所以一般情况下需要设置一下这个属性(*)
pagination: true, //是否显示分页(*)
sortable: true, //是否启用排序
sortOrder: "asc", //排序方式
queryParams: { comid: parentid }, //参数
ajaxOptions: { comid: parentid }, //ajax参数
sidePagination: "client", //分页方式:client客户端分页,server服务端分页(*)
pageNumber:1, //初始化加载第一页,默认第一页
pageSize: 10, //每页的记录行数(*)
pageList: [5,10, 25, 50, 100], //可供选择的每页的行数(*)
search: true, //是否显示表格搜索,此搜索是客户端搜索,不会进服务端,所以,个人感觉意义不大
//strictSearch: true,
showColumns: true, //是否显示所有的列
showRefresh: true, //是否显示刷新按钮
minimumCountColumns: 2, //最少允许的列数
clickToSelect: true, //是否启用点击选中行
//height: 500, //行高,如果没有设置height属性,表格自动根据记录条数觉得表格高度
uniqueId: "id", //每一行的唯一标识,一般为主键列
showToggle:true, //是否显示详细视图和列表视图的切换按钮
cardView: false, //是否显示详细视图
//detailView: true, //是否显示父子表
//showExport: true, //是否显示导出
//exportDataType: "basic", //basic', 'all', 'selected'.
//极为重要,缺失无法执行queryParams,传递page参数
//contentType : "application/x-www-form-urlencoded",
columns: [{
checkbox: true
}, {
field: 'id',
title: '公司编号',
sortable : true
}, {
field: 'title',
title: '招聘主题',
sortable : true
}, {
field: 'time',
title: '招聘时间',
sortable : true
} ],
});
原文:https://blog.csdn.net/u012078155/article/details/52083272