BootStrap Table - JS加载表格数据

 在初始化table的时候,参数最好是直接取, 按照temp[key] = value;的方式会在进行分页等操作时沿用页面初始化的参数.

参数传入可以使用 queryParams 对象

$(function () {
    //最大层级:2层
    initTable(2);
})

$(document).ready(function () {
    clearInputOnInit();

});

function clearInputOnInit() {
     ctlBeginTime.setValue("2016-12-01 00:00:00");
     ctlEndTime.setValue("2016-12-21 00:00:00");
}

function initTable(level) {
    var columns = [];

    $('#tabAudit').bootstrapTable({
        columns: columns,
        url: "/Business/FinancialManage/Biz_Audit_ProduceTask/LoadAuditProduceTaskFrist",
        queryParams: function (params) {
            var temp = {
                limit: params.limit,
                offset: params.offset,
                order: params.order,
                ordername: params.sort,
                beginTime: ctlBeginTime.getValue(),
                endTime: ctlEndTime.getValue()
            };
            //$.each(query, function (key, value) {
            //    temp[key] = value;
            //});
            return temp;
        },
        method: 'get',
        striped: true,
        pagination: true,
        sortName: "序号",
        sortOrder: "desc",
        sidePagination: "server",
        cache: false,
        pageNumber: 1,
        pageSize: 10,
        pageList: [5, 10, 20, 50, 100, 200],
        smartDisplay: false,
        rowStyle: function (row, index) {
            //颜色样式['active', 'success', 'info', 'warning', 'danger'];
            var strclass = "";
            if (row.ORDER_STATUS == "已审核") {
                strclass = 'success';
            }
            else {
                return {};
            }
            return { classes: strclass }
        },
        detailView: true,
        onExpandRow: function (index, row, $detail) {
            expandTable($detail, level - 1, row);
        }
    });
}

 

posted @ 2016-12-14 09:19  竹殇  阅读(3447)  评论(0编辑  收藏  举报