bootstrapTable请求后台数据,Server分页方式
如题,写过多次了,记个笔记。
function InitTable() {
$('#id').bootstrapTable({
url: '/Controller/Action', //请求后台的URL(*)
method: 'Post',
contentType: 'application/x-www-form-urlencoded; charset=UTF-8',//请求方式(*)若没有本行,后台获取不到数据。
// toolbar: '#usertable', //工具按钮用哪个容器
striped: true, //是否显示行间隔色
cache: false, //是否使用缓存,默认为true,所以一般情况下需要设置一下这个属性(*)
pagination: true, //启动分页 //是否显示分页(*)
sortOrder: "asc", //排序方式
queryParams: { operator: 'yes' },//传递参数(*)
sidePagination: "server", //分页方式:client客户端分页,server服务端分页(*)
pageSize: 10, //每页的记录行数(*)
pageNumber: 1, //初始化加载第一页,默认第一页
pageList: [10, 25, 50, 100], //可供选择的每页的行数(*)
clickToSelect: true,
//showExport: true, //是否显示导出
// exportDataType: "basic", //basic', 'all', 'selected'.
queryParamsType: "undefined",
queryParams: function queryParams(e) { //设置查询参数
//string recruitmentPlanId, string kAccount, int pageSize, int pageIndex
var param = {
pageIndex: e.pageNumber,
pageSize: e.pageSize,
kAccount: $("#kAccount").val().trim(),
recruitmentPlanId: 6,
};
return param;
},
columns: [{
field: 'id',
title: 'No.Id',
//visible: 'false'
}, {
field: 'kAccount',
title: 'K账号',
//formatter: 'fname'
}, {
field: 'permissions',
title: '操作'
}],
//onLoadSuccess: function (data) {
// console.log(data);
//},
});
}
仅供学习参考,如有侵权联系我删除