MVC中bootstrapTable父子表程式碼
阿新 • • 發佈:2019-02-12
$(function () {
$('#btable').bootstrapTable({
columns: [{
field: 'clas',
title: ' ',
valign: "middle",
align: "center"
}, {
field: 'subclas',
title: '分類',
valign: "middle",
align: "center"
}, {
field: 'num',
title: '數量',
valign: "middle",
align: "center"
}, {
field: 'totle',
title: '總價',
valign: "middle",
align: "center"
}, {
field: 'note',
title: '備註',
valign: "middle",
align: "center"
}],
data: mydata,
detailView: true,
//註冊載入子表的事件。注意下這裡的三個引數!
onExpandRow: function (index, row, $detail) {
var last = JSON.stringify(row);;
console.log(row);
onclick = row.id;
var parentId = row.id;
var prjLogBookProblemTable = $detail.html('<table></table>').find('table');
$(prjLogBookProblemTable).bootstrapTable({
columns: [
{
field: 'feiyongTypeName',
title: '費用明細',
align: 'center',
}
],
url: '/ProjCostManage/SummaryStep/GetSummaryOfDayDetail?keyValue=' + keyValue + '&index=' + index + '&row=' + last,
method: 'get',
queryParams: { parentId: parentId },
contentType: "application/x-www-form-urlencoded; charset=UTF-8",
onLoadError: function () { //載入失敗時執行
layer.msg("載入資料出錯!", { time: 1500, icon: 5 });
}
});
},
$('#btable').bootstrapTable({
columns: [{
field: 'clas',
title: ' ',
valign: "middle",
align: "center"
}, {
field: 'subclas',
title: '分類',
valign: "middle",
align: "center"
}, {
field: 'num',
title: '數量',
valign: "middle",
align: "center"
}, {
field: 'totle',
title: '總價',
valign: "middle",
align: "center"
}, {
field: 'note',
title: '備註',
valign: "middle",
align: "center"
}],
data: mydata,
detailView: true,
//註冊載入子表的事件。注意下這裡的三個引數!
onExpandRow: function (index, row, $detail) {
var last = JSON.stringify(row);;
console.log(row);
onclick = row.id;
var parentId = row.id;
var prjLogBookProblemTable = $detail.html('<table></table>').find('table');
$(prjLogBookProblemTable).bootstrapTable({
columns: [
{
field: 'feiyongTypeName',
title: '費用明細',
align: 'center',
}
],
url: '/ProjCostManage/SummaryStep/GetSummaryOfDayDetail?keyValue=' + keyValue + '&index=' + index + '&row=' + last,
method: 'get',
queryParams: { parentId: parentId },
contentType: "application/x-www-form-urlencoded; charset=UTF-8",
onLoadError: function () { //載入失敗時執行
layer.msg("載入資料出錯!", { time: 1500, icon: 5 });
}
});
},
});
<table id="btable"></table>