如何在引导程序子表中隐藏标题

How to hide headers in bootstrap subtables

本文关键字:隐藏 标题 引导程序      更新时间:2023-09-26

我正在尝试自定义这个fiddle中的代码https://jsfiddle.net/dabros/vuLj1bcb/

var $table = $('#table');
$(function() {
 $table.bootstrapTable({
columns: [{
  field: 'col1',
  title: 'Col1'
}, {
  field: 'col2',
  title: 'Col2'
}],
data: data,
detailView: true,
onExpandRow: function(index, row, $detail) {
  console.log(row)
  $detail.html('<table></table>').find('table').bootstrapTable({
    columns: [{
      field: 'col3',
      title: 'Col3'
    }, {
      field: 'col4',
      title: 'Col4'
    }, {
      field: 'col5',
      title: 'Col5'
    }],
    data: row.nested,
    // Simple contextual, assumes all entries have further nesting
    // Just shows example of how you might differentiate some rows, though also remember row class and similar possible flags
    detailView: row.nested[0]['other'] !== undefined,
    onExpandRow: function(indexb, rowb, $detailb) {
      $detailb.html('<table></table>').find('table').bootstrapTable({
        columns: [{
          field: 'col6',
          title: 'Col6'
        }, {
          field: 'col7',
          title: 'Col7'
        }],
        data: rowb.other
          });
        }
      });
   }
  });
});

从而不显示子表的标题。很明显,我必须在标题中使用类似"display:none"的内容,但我不知道在哪里进行更改。知道吗?

在文档中:
http://bootstrap-table.wenzhixin.net.cn/documentation/
有一个选项showHeader可以设置为false
表选项在jQuery.fn.bootstrapTable.defaults 中定义

由于您可能想要使用他们的CDN,因此可以在表的thead元素上添加display: none