bootstrapr表格父子框_使用Bootstrap Table建立父子表

这篇博客介绍了如何利用Bootstrap Table库来实现一个具有父子表格功能的表格。展示了如何初始化主表格,并在展开每一行时动态加载对应的子表格数据,详细配置了表格的各项参数,包括排序、分页和列设置。
摘要由CSDN通过智能技术生成

代码$(function() {var oTableInit = newObject();var oInit = newObject();

$('#tb_agentService').bootstrapTable({

data: [

{"no": "FF21135", "type": "生产单元一", "name": "PVHI", "money": 35},

{"no": "FF21135", "type": "生产单元一", "name": "PVHI", "money": 35},

{"no": "FF21135", "type": "生产单元一", "name": "PVHI", "money": 35},

{"no": "FF21135", "type": "生产单元一", "name": "PVHI", "money": 35},

{"no": "FF21135", "type": "生产单元一", "name": "PVHI", "money": 35},

{"no": "FF21135", "type": "生产单元一", "name": "PVHI", "money": 35},

{"no": "FF21135", "type": "生产单元一", "name": "PVHI", "money": 35},

{"no": "FF21135", "type": "生产单元一", "name": "PVHI", "money": 35},

{"no": "FF21135", "type": "生产单元一", "name": "PVHI", "money": 35},

{"no": "FF21135", "type": "生产单元一", "name": "PVHI", "money": 35},

{"no": "FF21135", "type": "生产单元一", "name": "PVHI", "money": 35},

{"no": "FF21135", "type": "生产单元一", "name": "PVHI", "money": 35},

{"no": "FF21135", "type": "生产单元一", "name": "PVHI", "money": 35},

{"no": "FF21135", "type": "生产单元一", "name": "PVHI", "money": 35},

],

paginationPreText:'

paginationNextText:'>',

detailView:true, //父子表

striped:true, //是否显示行间隔色

pagination:true, //是否显示分页(*)

sortOrder:"asc", //排序方式

pageNumber:1, //初始化加载第一页,默认第一页

height:400,

pageSize:10, //每页的记录行数(*)

pageList: [10, 20], //可供选择的每页的行数(*)

columns: [{

title:"序号",

formatter:function(value, row, index) {return index + 1;

},

rowspan:1,

align:'center',

width:'50px'},{

field:'no',

title:'位号',

align:'left',

}, {

field:'type',

title:'生产单元',

align:'left',

}, {

field:'name',

title:'报警标识',

align:'center',

}, {

field:'money',

title:'数量',

align:'right',

}

],

onExpandRow:function(index, row, $detail) {

oTableInit.InitSubTable(index, row, $detail);

}

});

oTableInit.InitSubTable= function(index, row, $detail) {var parentid =row.MENU_ID;var cur_table = $detail.html('

').find('table');

$(cur_table).bootstrapTable({

data: [{"no": "FF21135", "type": "生产单元一", "name": "PVHI", "money": 503, "time": "34.65", "matter": '98.05'},

{"no": "FF21135", "type": "生产单元一", "name": "PVHI", "money": 503, "time": "34.65", "matter": '98.05'},

{"no": "FF21135", "type": "生产单元一", "name": "PVHI", "money": 503, "time": "34.65", "matter": '98.05'},

{"no": "FF21135", "type": "生产单元一", "name": "PVHI", "money": 503, "time": "34.65", "matter": '98.05'},

{"no": "FF21135", "type": "生产单元一", "name": "PVHI", "money": 503, "time": "34.65", "matter": '98.05'},

{"no": "FF21135", "type": "生产单元一", "name": "PVHI", "money": 503, "time": "34.65", "matter": '98.05'},

{"no": "FF21135", "type": "生产单元一", "name": "PVHI", "money": 503, "time": "34.65", "matter": '98.05'},

],

method:'get',

queryParams: { strParentID: parentid },

ajaxOptions: { strParentID: parentid },

clickToSelect:true,

pagination:true, //是否显示分页(*)

sortOrder:"asc", //排序方式

pageNumber:1, //初始化加载第一页,默认第一页

height:260,

pageSize:6, //每页的记录行数(*)

pageList: [6, 12, 24, 48], //可供选择的每页的行数(*)

paginationPreText:'

paginationNextText:'>',

columns: [{

title:"序号",

formatter:function(value, row, index) {return index + 1;

},

rowspan:1,

align:'center',

width:'50px'},{

field:'no',

title:'子位号',

align:'left',

}, {

field:'type',

title:'生产单元',

align:'left',

}, {

field:'name',

title:'报警标识',

align:'center',

}, {

field:'money',

title:'报警数',

align:'right',

},

{

field:'time',

title:'可预测性(%)',

align:'right',

},

{

field:'matter',

title:'重要的(%)',

align:'right',

}

],//无线循环取子表,直到子表里面没有记录

onExpandRow:function(index, row, $Subdetail) {

oInit.InitSubTable(index, row, $Subdetail);

}

});returnoTableInit;

};

});

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值