浏览代码

added table option to hide/show the detail view icon column

Dustin Utecht 6 年之前
父节点
当前提交
299086fecd
共有 2 个文件被更改,包括 16 次插入3 次删除
  1. 12 0
      site/docs/api/table-options.md
  2. 4 3
      src/bootstrap-table.js

+ 12 - 0
site/docs/api/table-options.md

@@ -1184,6 +1184,18 @@ The table options are defined in `jQuery.fn.bootstrapTable.defaults`.
 
 
 - **Example:** [Detail View](https://examples.bootstrap-table.com/#options/detail-view.html)
 - **Example:** [Detail View](https://examples.bootstrap-table.com/#options/detail-view.html)
 
 
+## showDetailView
+
+- **Attribute:** `data-show-detail-view`
+
+- **Type:** `Boolean`
+
+- **Detail:**
+
+  Set `true` to show the detail view column (plus/minus icon).
+
+- **Default:** `true`
+
 ## detailFormatter
 ## detailFormatter
 
 
 - **Attribute:** `data-detail-formatter`
 - **Attribute:** `data-detail-formatter`

+ 4 - 3
src/bootstrap-table.js

@@ -451,6 +451,7 @@
     uniqueId: undefined,
     uniqueId: undefined,
     cardView: false,
     cardView: false,
     detailView: false,
     detailView: false,
+    showDetailView: true,
     detailViewByClick: false,
     detailViewByClick: false,
     detailFormatter (index, row) {
     detailFormatter (index, row) {
       return ''
       return ''
@@ -877,7 +878,7 @@
       this.options.columns.forEach((columns, i) => {
       this.options.columns.forEach((columns, i) => {
         html.push('<tr>')
         html.push('<tr>')
 
 
-        if (i === 0 && !this.options.cardView && this.options.detailView) {
+        if (i === 0 && !this.options.cardView && this.options.detailView && this.options.showDetailView) {
           html.push(`<th class="detail" rowspan="${this.options.columns.length}">
           html.push(`<th class="detail" rowspan="${this.options.columns.length}">
             <div class="fht-cell"></div>
             <div class="fht-cell"></div>
             </th>
             </th>
@@ -1871,7 +1872,7 @@
         html.push(`<td colspan="${this.header.fields.length}"><div class="card-views">`)
         html.push(`<td colspan="${this.header.fields.length}"><div class="card-views">`)
       }
       }
 
 
-      if (!this.options.cardView && this.options.detailView) {
+      if (!this.options.cardView && this.options.detailView && this.options.showDetailView) {
         html.push('<td>')
         html.push('<td>')
 
 
         if (Utils.calculateObjectValue(null, this.options.detailFilter, [i, item])) {
         if (Utils.calculateObjectValue(null, this.options.detailFilter, [i, item])) {
@@ -2450,7 +2451,7 @@
       const data = this.getData()
       const data = this.getData()
       const html = []
       const html = []
 
 
-      if (!this.options.cardView && this.options.detailView) {
+      if (!this.options.cardView && this.options.detailView && this.options.showDetailView) {
         html.push('<th class="detail"><div class="th-inner"></div><div class="fht-cell"></div></th>')
         html.push('<th class="detail"><div class="th-inner"></div><div class="fht-cell"></div></th>')
       }
       }