原创

bootstrap table 表头合并单元格

由于我此处是没有url请求的,所以data数据直接写死了,但是不影响其他操作,只是关注于表头合并单元格

详细说一下表头处,设置表头时候,colspan为跨行的标志,rowspan为跨列的标志。在columns:里,,按照一行一行的写,一行是一个[],然后设置跨几行跨几列,若有下方不是直接对应数据,就是下方还有其他分的表头,则不需要设置field,具体看如下代码:


$(".dataTable").bootstrapTable('destroy').bootstrapTable({
            /*   columns: columns,*/
            // url: queryUrl,                      //请求后台的URL(*)
            // method: 'POST',                      //请求方式(*)
            // dataField: 'records',
            // contentType: "application/x-www-form-urlencoded",
            // classes: 'table table-striped table-borderless table-hover',
            pageNumber: 1, //初始化加载第一页
            pagination:false,//是否分页
            detailView: false,//父子表
            sidePagination:'client',//server:服务器端分页|client:前端分页
            pageSize:10,//单页记录数
            //  pageList: [10, 20, 50, 100],
            /* paginationHAlign:'left',*/
            formatShowingRows: function (pageFrom, pageTo, totalRows) {
                return '显示第 ' + pageFrom + ' 到第 ' + pageTo + ' 条记录,总共 ' + totalRows + ' 条记录';
            },
            columns:
                [

                    [
                        /*{
                            field: 'id',
                            title: "序号",
                            valign:"middle",
                            align:"center",
                            colspan: 1,
                            rowspan: 3,
                            formatter: function (value, row, index) {
                                return index+1;
                            }
                        },*/
                        {

                            field: 'cuf',
                            title: "c(μF)",
                            valign:"middle",
                            align:"center",
                            colspan: 1,
                            rowspan: 3
                        },
                        {
                            title: "轨道长度LV(M)",
                            valign:"middle",
                            align:"center",
                            colspan: 2,
                            rowspan: 2
                        },
                        {
                            field: 'drsl',
                            title: "电容数量Nc",
                            valign:"middle",
                            align:"center",
                            colspan: 1,
                            rowspan: 3
                        },
                        {
                            field: 'jsdpj',
                            title: "接受电平级Krv",
                            valign:"middle",
                            align:"center",
                            colspan: 1,
                            rowspan: 3
                        } ,
                        {

                            title: "接收端各点电压(V)",
                            valign:"middle",
                            align:"center",
                            colspan: 6,
                            rowspan: 1
                        } ,
                        {

                            title: "发送端各点电压/电流(V/I)",
                            valign:"middle",
                            align:"center",
                            colspan: 7,
                            rowspan: 1
                        } ,
                    ],
                    [

                        {
                            title: '主轨出VR1R2(V)',
                            valign:"middle",
                            align:"center",
                            colspan: 2,
                            rowspan: 1
                        },
                        {
                            title: '轨入VV1V2(V)',
                            valign:"middle",
                            align:"center",
                            colspan: 2,
                            rowspan: 1
                        },
                        {
                            title: '轨面(V)',
                            valign:"middle",
                            align:"center",
                            colspan: 2,
                            rowspan: 1
                        },{
                        title: '轨面(V)',
                        valign:"middle",
                        align:"center",
                        colspan: 2,
                        rowspan: 1
                    },
                        {
                            title: '轨出电压(V)',
                            valign:"middle",
                            align:"center",
                            colspan: 2,
                            rowspan: 1
                        },
                        {
                            title: '轨出电流(V)',
                            valign:"middle",
                            align:"center",
                            colspan: 2,
                            rowspan: 1
                        },
                        {
                            title: '功出电平',
                            valign:"middle",
                            align:"center",
                            colspan: 1,
                            rowspan: 1
                        }
                    ],
                    [
                        {
                            field: 'gdcdmin',
                            title: "min",
                            valign:"middle",
                            align:"center",
                        },{
                        field: 'gdcdmax',
                        title: "max",
                        valign:"middle",
                        align:"center",
                    },{
                        field: 'jszgcmin',
                        title: "min",
                        valign:"middle",
                        align:"center",
                    },{
                        field: 'jszgcmax',
                        title: "max",
                        valign:"middle",
                        align:"center",
                    },{
                        field: 'jsgrmin',
                        title: "min",
                        valign:"middle",
                        align:"center",
                    },{
                        field: 'jsgrmax',
                        title: "max",
                        valign:"middle",
                        align:"center",
                    },{
                        field: 'jsgmmin',
                        title: "min",
                        valign:"middle",
                        align:"center",
                    },{
                        field: 'jsgmmax',
                        title: "max",
                        valign:"middle",
                        align:"center",
                    },{
                        field: 'fsgmmin',
                        title: "min",
                        valign:"middle",
                        align:"center",
                    },{
                        field: 'fsgmmax',
                        title: "max",
                        valign:"middle",
                        align:"center",
                    },{
                        field: 'fsgcdymin',
                        title: "min",
                        valign:"middle",
                        align:"center",
                    },{
                        field: 'fsgcdymax',
                        title: "max",
                        valign:"middle",
                        align:"center",
                    },{
                        field: 'fsgcdlmin',
                        title: "min",
                        valign:"middle",
                        align:"center",
                    },{
                        field: 'fsgcdlmax',
                        title: "max",
                        valign:"middle",
                        align:"center",
                    },{
                        field: 'fsgcdp',
                        title: "Kem",
                        valign:"middle",
                        align:"center",
                    }
                    ]
                ],
            data:[
            {
                cuf: "25",
                drsl: "5",
                jsdpj: "22",
                gdcdmin: "301",
                gdcdmax: "350",
                jszgcmin: "0.24",
                jszgcmax: "0.327",
                jsgrmin: "1.31",
                jsgrmax: "1.723",
                jsgmmin: "1.606",
                jsgmmax: "2.013",
                fsgmmin: "2.382",
                fsgmmax: "2.704",
                fsgcdymin: "146.81",
                fsgcdymax: "160.05",
                fsgcdlmin: "0.292",
                fsgcdlmax: "0.324",
                fsgcdp: "2"
            },
            {
                cuf: "25",
                gdcdmin: "351",
                gdcdmax: "400",
                drsl: "6",
                jsdpj: "22",
                jszgcmin: "0.24",
                jszgcmax: "0.322",
                jsgrmin: "1.284",
                jsgrmax: "1.699",
                jsgmmin: "1.574",
                jsgmmax: "1.985",
                fsgmmin: "2.219",
                fsgmmax: "2.509",
                fsgcdymin: "146.78",
                fsgcdymax: "159.98",
                fsgcdlmin: "0.289",
                fsgcdlmax: "0.321",
                fsgcdp: "2"
            },{
                cuf: "25",
                gdcdmin: "401",
                gdcdmax: "450",
                drsl: "7",
                jsdpj: "23",
                jszgcmin: "0.24",
                jszgcmax: "0.329",
                jsgrmin: "1.243",
                jsgrmax: "1.662",
                jsgmmin: "1.524",
                jsgmmax: "1.942",
                fsgmmin: "2.199",
                fsgmmax: "2.435",
                fsgcdymin: "146.83",
                fsgcdymax: "160.02",
                fsgcdlmin: "0.285",
                fsgcdlmax: "0.317",
                fsgcdp: "2"
            },{
                cuf: "25",
                gdcdmin: "451",
                gdcdmax: "500",
                drsl: "8",
                jsdpj: "24",
                jszgcmin: "0.24",
                jszgcmax: "0.333",
                jsgrmin: "1.193",
                jsgrmax: "1.612",
                jsgmmin: "1.462",
                jsgmmax: "1.883",
                fsgmmin: "2.299",
                fsgmmax: "2.521",
                fsgcdymin: "146.92",
                fsgcdymax: "160.12",
                fsgcdlmin: "0.284",
                fsgcdlmax: "0.314",
                fsgcdp: "2"
            },{
                cuf: "25",
                gdcdmin: "501",
                gdcdmax: "550",
                drsl: "9",
                jsdpj: "25",
                jszgcmin: "0.24",
                jszgcmax: "0.373",
                jsgrmin: "1.268",
                jsgrmax: "1.732",
                jsgmmin: "1.554",
                jsgmmax: "2.024",
                fsgmmin: "2.682",
                fsgmmax: "2.976",
                fsgcdymin: "163.2",
                fsgcdymax: "178.17",
                fsgcdlmin: "0.317",
                fsgcdlmax: "0.35",
                fsgcdp: "1"
            },{
                cuf: "25",
                gdcdmin: "551",
                gdcdmax: "600",
                drsl: "10",
                jsdpj: "26",
                jszgcmin: "0.24",
                jszgcmax: "0.376",
                jsgrmin: "1.219",
                jsgrmax: "1.679",
                jsgmmin: "1.494",
                jsgmmax: "1.962",
                fsgmmin: "2.741",
                fsgmmax: "3.097",
                fsgcdymin: "163.19",
                fsgcdymax: "178.2",
                fsgcdlmin: "0.319",
                fsgcdlmax: "0.353",
                fsgcdp: "1"
            },{
                cuf: "25",
                gdcdmin: "601",
                gdcdmax: "650",
                drsl: "10",
                jsdpj: "27",
                jszgcmin: "0.24",
                jszgcmax: "0.382",
                jsgrmin: "1.174",
                jsgrmax: "1.641",
                jsgmmin: "1.44",
                jsgmmax: "1.917",
                fsgmmin: "2.797",
                fsgmmax: "3.2",
                fsgcdymin: "163.2",
                fsgcdymax: "178.23",
                fsgcdlmin: "0.321",
                fsgcdlmax: "0.355",
                fsgcdp: "1"
            },{
                cuf: "25",
                gdcdmin: "601",
                gdcdmax: "650",
                drsl: "10",
                jsdpj: "27",
                jszgcmin: "0.24",
                jszgcmax: "0.382",
                jsgrmin: "1.174",
                jsgrmax: "1.641",
                jsgmmin: "1.44",
                jsgmmax: "1.917",
                fsgmmin: "2.797",
                fsgmmax: "3.2",
                fsgcdymin: "163.2",
                fsgcdymax: "178.23",
                fsgcdlmin: "0.321",
                fsgcdlmax: "0.355",
                fsgcdp: "1"
            },{
                cuf: "25",
                gdcdmin: "601",
                gdcdmax: "650",
                drsl: "10",
                jsdpj: "27",
                jszgcmin: "0.24",
                jszgcmax: "0.382",
                jsgrmin: "1.174",
                jsgrmax: "1.641",
                jsgmmin: "1.44",
                jsgmmax: "1.917",
                fsgmmin: "2.797",
                fsgmmax: "3.2",
                fsgcdymin: "163.2",
                fsgcdymax: "178.23",
                fsgcdlmin: "0.321",
                fsgcdlmax: "0.355",
                fsgcdp: "1"
            },{
                cuf: "25",
                gdcdmin: "601",
                gdcdmax: "650",
                drsl: "10",
                jsdpj: "27",
                jszgcmin: "0.24",
                jszgcmax: "0.382",
                jsgrmin: "1.174",
                jsgrmax: "1.641",
                jsgmmin: "1.44",
                jsgmmax: "1.917",
                fsgmmin: "2.797",
                fsgmmax: "3.2",
                fsgcdymin: "163.2",
                fsgcdymax: "178.23",
                fsgcdlmin: "0.321",
                fsgcdlmax: "0.355",
                fsgcdp: "1"
            },{
                cuf: "25",
                gdcdmin: "601",
                gdcdmax: "650",
                drsl: "10",
                jsdpj: "27",
                jszgcmin: "0.24",
                jszgcmax: "0.382",
                jsgrmin: "1.174",
                jsgrmax: "1.641",
                jsgmmin: "1.44",
                jsgmmax: "1.917",
                fsgmmin: "2.797",
                fsgmmax: "3.2",
                fsgcdymin: "163.2",
                fsgcdymax: "178.23",
                fsgcdlmin: "0.321",
                fsgcdlmax: "0.355",
                fsgcdp: "1"
            }
        ]

        });

效果图:
file

正文到此结束
本文目录