我正在使用wenzhixin引导表,并且我试图在子行中获得另一个引导表来初始化它,在代码中称为‘细节视图’。
我使用的是数据,但到目前为止,这似乎更简单,更直接的工作。
我将把密钥从父行传递给子行。现在,我只是使用一个静态表来初始化子行之外的表,现在我只是将它移动到子行,试图使它初始化,然后我将使内容动态。
数据正在传递,但表似乎没有初始化。我想知道是否需要隐藏一个可以在幕后初始化的表,然后将内容传递给行(看起来很麻烦,但我想不出另一种方法来实现这一点)。
我的代码使主表中的detailView无效;
detailView: true,
detailFormatter: 'compExtInfo',下面是我返回子行的内容(detailView)
function compExtInfo(index, row) {
var pAPI = row.api;
var hOut = '<table data-toggle="table" data-url="./completion/getcompletionext.php?api=49-037-28606">'+
'<thead>'+
'<tr>'+
'<th data-field="api" data-visible=false>API</th>'+
'<th data-field="finalfieldreport">Last Fld Rp</th>'+
'<th data-field="onbase">OnBase</th>'+
'<th data-field="tbg">Tbg</th>'+
'<th data-field="active">Actv</th>'+
'</tr>'+
'</thead>'+
'</table>';
console.log(hOut);
return hOut;
}下面是如果单独放置在子表之外的表/网格,它将完全初始化(与上面相同的代码,字面上是复制并粘贴到函数中)。
<table data-toggle="table" data-url="./completion/getcompletionext.php?api=49-037-28606">
<thead>
<tr>
<th data-field="api" data-visible=false>API</th>
<th data-field="finalfieldreport">Last Fld Rp</th>
<th data-field="onbase">OnBase</th>
<th data-field="tbg">Tbg</th>
<th data-field="active">Actv</th>
</tr>
</thead>
</table>发布于 2015-08-06 13:28:06
最后,我找到了一个解决方案,下面列出了代码。
下面列出的子行的主表初始化;
detailView: true,
onExpandRow: function (index, row, $detail) {
compExtInfo($detail, row);}从主表调用的函数;获取行键并传递给表生成器。
function compExtInfo($detail, row) {
pAPI = row.api;
buildTable($detail.html('<table></table>').find('table'), pAPI);
}表生成器函数
function buildTable($ext, api) {
$ext.bootstrapTable({
url: './completion/getcompletionext.php?api='+api,
columns: [
{
field: 'api',
visible: false,
title: 'API'
},{
field: 'finalfieldreport',
title: 'Last Fld Rp'
...
]
});
}发布于 2016-05-16 17:08:18
主表中的事件
table.on('expand-row.bs.table', function (e, index, row, $detail) {
var tableD = $detail.append('<table id="table_' + row["impresora"] + '"></table>').find('table');
tableD.bootstrapTable({
editable: true,
showHeader: false,
idField: 'ip',
method: 'get',
dataType: "json",
url: baseUrl + 'app_modules/Cups/classes/admin_impresoras.php?accion=get&impresora=' + row['impresora'],
columns: [
{
title: 'IMPRESORA',
field: 'impresora',
halign: 'left',
valign: 'middle',
visible: false
},
{
title: 'IP',
field: 'ip',
halign: 'left',
valign: 'middle',
sortable: true,
editable: {
type: 'text',
url: baseUrl + 'app_modules/Cups/classes/admin_impresoras.php?accion=updateip&impresora=' + row['impresora'],
ajaxOptions: {
type: 'POST'//,
}
, success: function (text) {
if (text === "success") {
} else
alert(text);
}
}
},
{
title: 'PREDETERMINADA',
field: 'sw_predeterminada',
halign: 'left',
valign: 'middle',
sortable: true,
editable: {
type: 'text',
url: baseUrl + 'app_modules/Cups/classes/admin_impresoras.php?accion=updateip&impresora=' + row['impresora'],
ajaxOptions: {
type: 'POST'//,
}
, success: function (text) {
if (text === "success") {
} else
alert(text);
}
}
}
]
});
});
https://stackoverflow.com/questions/31840120
复制相似问题