bootstrapTable初始化常用参数

bootstrapTable初始化常用参数,前端分页排序,后端获取表格数据

$('#table').bootstrapTable({
    toolbar: '#mybar',                //工具按钮用哪个容器
    striped: true,                      //是否显示行间隔色
    cache: false,                       //是否使用缓存,默认为true,所以一般情况下需要设置一下这个属性(*)
    sortable: true,                    //是否启用排序
    sortOrder: "asc",                   //排序方式
    showColumns: true,                  //是否显示所有的列
    showRefresh: true,                  //是否显示刷新按钮
    minimumCountColumns: 2,             //最少允许的列数
    clickToSelect: true,                //是否启用点击选中行
    uniqueId: "ID",                     //每一行的唯一标识,一般为主键列
    showToggle: true,                    //是否显示详细视图和列表视图的切换按钮
    cardView: false,                    //是否显示详细视图
    detailView: false,                   //是否显示父子表
    columns: columnsdata,
    pagination: true,
    pageList: [10, 20, 30, 40, 'all'],
    loading: '数据加载中...',
    pageSize: 10,
    pageNumber: 1,
    showExport: true,
    exportDataType: 'all',              //basic', 'all', 'selected'.
    exportTypes: ['excel'],      //导出类型
    exportOptions: {
        ignoreColumn: [0, 0],            //忽略某一列的索引
        fileName: $('#myModal .modal-header h4').text(),              //文件名称设置
        worksheetName: 'Sheet1',          //表格工作区名称
        tableName: $('#myModal .modal-header h4').text(),
        excelstyles: ['background-color', 'color', 'font-size', 'font-weight'],
    },
    method: 'get',
    datatype: 'json',
    url: "/user/query",//这个接口需要处理bootstrap table传递的固定参数
    queryParamsType: '', //默认值为 'limit' ,在默认情况下 传给服务端的参数为:offset,limit,sort

    queryParams: function () {
        let params = {keyword: $("#search_keys").val().replace(/[ ]/g, "").replace(/	/g, "")}
        return params
    },//前端调用服务时,会默认传递上边提到的参数,如果需要添加自定义参数,可以自定义一个函数返回请求参数
    responseHandler: function (res) {
return res.data
    },

});
原文地址:https://www.cnblogs.com/cherylgi/p/13490167.html