js/bootstrapTable表格动态设置表头

第一步:定义对象存放列内容;

var colummvalue=[];

colummvalue.push([{
                field: 'selectItem',
                title: '',
                width: '36px',
                radio: true,
                visible: true
            },
            {
                field: 'col2',
                title: '科目',
                align: 'center',
                colspan: '2'
            },
            {
                field: 'col3',
                title: '期初余额',
                align: 'center',
                colspan: '2'
            },
            {
                field: 'col4',
                title: '本期发生',
                align: 'center',
                colspan: '2'
            },
            {
                field: 'col5',
                title: '期末余额',
                align: 'center',
                colspan: '3'
            }],
                [{
                    field: 'selectItem',
                    title: '',
                    width: '36px',
                    radio: true
                },
                {
                    field: 'itembm',
                    title: '科目编码',
                    width: '60'
                },
                {
                    field: 'kmmc',
                    title: '科目名称',
                    align: 'center',
                    width: '260px',
                },
                {
                    field: 'jfje0',
                    title: '借方',
                    align: 'center',
                    tbalign: 'right',
                    footerFormatter: function (value) {
                        return toformats(value);
                    }
                },
                {
                    field: 'dfje0',
                    title: '贷方',
                    align: 'center',
                    tbalign: 'right',
                    footerFormatter: function (value) {

                        return toformats(value);
                    }
                },
                {
                    field: 'jfje',
                    title: '借方',
                    tbalign: 'right',
                    footerFormatter: function (value) {

                        return toformats(value);
                    }
                },
                {
                    field: 'dfje',
                    title: '贷方',
                    tbalign: 'right',
                    footerFormatter: function (value) {
                        return toformats(value);
                    }
                },
                {
                    field: 'jfje2',
                    title: '借方',
                    tbalign: 'right',
                    footerFormatter: function (value) {
                        return toformats(value);
                    }
                },
                {
                    field: 'dfje2',
                    title: '贷方',
                    align: 'center',
                    tbalign: 'right',
                    footerFormatter: function (value) {

                        return toformats(value);
                    }
                }
               ]);

第二步:引用上面的对象colummvalue

$('#gridTable').ysTable({
            method: 'get',
            url: urls,
            dataType: "text",
            contentType: 'application/json',
            pageNumber: 1, //初始化加载第一页
            pagination: true,//是否分页
            sidePagination: 'client',//server:服务器端分页|client:前端分页
            //pageSize: 4,//单页记录数
            pageList: [5, 10, 15, 20, 30],//可选择单页记录数
            showRefresh: true,//刷新按钮
            showFooter: true,  //开启底部
            queryParams: function (params) {//上传服务器的参数
                var temp = {
                    Value1: encodeURIComponent(bTest),
                };
                return temp;
            },
            responseHandler: function (data) {
                data = JSON.parse(Decrypt(data) + "");
                console.log(data);
                return data;
            },
            columns: colummvalue,
            onLoadSuccess: function (obj) {
                //tfootertab("gridTable");//底部设置
            },
            onLoadError: function (data) {
                //console.log(data);
            }
        });

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值