ソースを参照

Merge branch 'feature/separate-files' of https://github.com/wenzhixin/bootstrap-table into feature/separate-files

djhvscf 5 年 前
コミット
74ae08069a
2 ファイル変更113 行追加14 行削除
  1. 23 7
      CHANGELOG.md
  2. 90 7
      src/extensions/print/bootstrap-table-print.js

+ 23 - 7
CHANGELOG.md

@@ -1,16 +1,24 @@
 ChangeLog
 ---------
 
-### 1.16.1
+### 1.17.0
 
 #### Core
 
-- **Add:** Added `$index` field for `remove` method.
-- **Add:** Added `on-all` event for vue component.
-- **Add:** Added `bg-BG` locale.
-- **Add:** Added `loadingFontSize` option.
-- **Add:** Added `loadingTemplate` option.
-- **Add:** Added `detailView` support for `cardView`.
+- **New:** Added `bootstrap-table` theme without any framework.
+- **New:** Added support for Bootstrap v5.
+- **New:** Added `$index` field for `remove` method.
+- **New:** Added `on-all` event for vue component.
+- **New:** Added `bg-BG` locale.
+- **New:** Added `loadingFontSize` option.
+- **New:** Added `loadingTemplate` option.
+- **New:** Added `detailView` support for `cardView`.
+- **New:** Added the `searchable` columns to the query params for server side.
+- **New:** Added `collapseRowByUniqueId` and `expandRowByUniqueId` methods.
+- **New:** Added `detailViewAlign` option for the detail view icon.
+- **New:** Added tr `class` support for `thead`.
+- **New:** Added `formatted` parameter for `getData` method to get formatted data.
+- **New:** Added `paginationParts` option instead of `onlyInfoPagination`.
 - **Update:** Fixed `updateByUniqueId` method cannot update multiple rows bug.
 - **Update:** Fixed `insertRow` not write to source data array bug.
 - **Update:** Fixed events bug with `detailViewIcon` option.
@@ -21,16 +29,23 @@ ChangeLog
 - **Update:** Fixed `font-size` of the loading text.
 - **Update:** Fixed table `border` bug when table is hidden.
 - **Update:** Fixed `showRow` method show all hidden rows bug.
+- **Remove:** Removed the `onlyInfoPagination` option.
 
 #### Extensions
 
+- **New(cookie)**: Added support for toggle all columns options.
 - **New(custom-view):** Added `custom-view` extension.
 - **New(editable):** Added `alwaysUseFormatter` option.
 - **New(export):** Added `forceHide` column option.
 - **New(filter-control):** Added `filterOrderBy` column option support order by `server`.
 - **New(filter-control):** Added radio support for `filterControlContainer`.
+- **New(filter-control):** Added `filterControlVisible` option and `toggleFilterControl` method.
+- **New(filter-control):** Added `showFilterControlSwitch` option.
 - **New(fixed-columns):** Added support for sticky-header.
 - **New(pipeline):** Added `pipeline` extension.
+- **Update(accent-neutralise):** Fixed comparison with arrays.
+- **Update(cookie):** Updated cookie columns to always visible when `switchable` is `false`.
+- **Update(cookie):** Fixed cookie value from existing options bug.
 - **Update(editable):** Fixed not handle quotation marks bug.
 - **Update(editable):** Updated `noeditFormatter` to `noEditFormatter`.
 - **Update(export):** Fixed export error with `maintainMetaData` and `clientSidePagination`.
@@ -38,6 +53,7 @@ ChangeLog
 - **Update(filter-control):** Fixed ignore default search text bug.
 - **Update(filter-control):** Fixed not work with html formatter.
 - **Update(filter-control):** Fixed reset `filterBy` method bug.
+- **Update(filter-control):** Fixed issue with a custom filter control container.
 - **Update(fixed-columns):** Fixed loading message not hide bug.
 - **Update(group-by):** Fixed params error of `checkAll`/`uncheckAll`.
 - **Update(multiple-sort):** Fixed not working with multiple level field bug.

+ 90 - 7
src/extensions/print/bootstrap-table-print.js

@@ -72,6 +72,16 @@ $.extend($.fn.bootstrapTable.defaults.icons, {
 })
 
 $.BootstrapTable = class extends $.BootstrapTable {
+  init (...args) {
+    super.init(...args)
+
+    if (!this.options.showPrint) {
+      return
+    }
+
+    this.mergedCells = []
+  }
+
   initToolbar (...args) {
     this.showToolbar = this.showToolbar || this.options.showPrint
 
@@ -98,8 +108,29 @@ $.BootstrapTable = class extends $.BootstrapTable {
     })
   }
 
+  mergeCells (options) {
+    super.mergeCells(options)
+
+    if (!this.options.showPrint) {
+      return
+    }
+
+    let col = this.getVisibleFields().indexOf(options.field)
+
+    if (Utils.hasDetailViewIcon(this.options)) {
+      col += 1
+    }
+
+    this.mergedCells.push({
+      row: options.index,
+      col,
+      rowspan: options.rowspan || 1,
+      colspan: options.colspan || 1
+    })
+  }
+
   doPrint (data) {
-    const formatValue = (row, i, column ) => {
+    const formatValue = (row, i, column) => {
       const value = Utils.calculateObjectValue(column, column.printFormatter,
         [row[column.field], row, i], row[column.field])
 
@@ -127,20 +158,73 @@ $.BootstrapTable = class extends $.BootstrapTable {
 
       html.push('</thead><tbody>')
 
+      const dontRender = []
+      if (this.mergedCells) {
+        for (let mc = 0; mc < this.mergedCells.length; mc++) {
+          const currentMergedCell = this.mergedCells[mc]
+          for (let rs = 0; rs < currentMergedCell.rowspan; rs++) {
+            const row = currentMergedCell.row + rs
+            for (let cs = 0; cs < currentMergedCell.colspan; cs++) {
+              const col = currentMergedCell.col + cs
+              dontRender.push(row + ',' + col)
+            }
+          }
+        }
+      }
+
       for (let i = 0; i < data.length; i++) {
         html.push('<tr>')
 
         for (const columns of columnsArray) {
           for (let j = 0; j < columns.length; j++) {
-            if (!columns[j].printIgnore && columns[j].field) {
-              html.push('<td>', formatValue(data[i], i, columns[j]), '</td>')
+            let rowspan = 0
+            let colspan = 0
+            if (this.mergedCells) {
+              for (let mc = 0; mc < this.mergedCells.length; mc++) {
+                const currentMergedCell = this.mergedCells[mc]
+                if (currentMergedCell.col === j && currentMergedCell.row === i) {
+                  rowspan = currentMergedCell.rowspan
+                  colspan = currentMergedCell.colspan
+                }
+              }
+            }
+
+            if (
+              !columns[j].printIgnore && columns[j].field
+              && (
+                !dontRender.includes(i + ',' + j)
+                || (rowspan > 0 && colspan > 0)
+              )
+            ) {
+              if (rowspan > 0 && colspan > 0) {
+                html.push(`<td ${Utils.sprintf(' rowspan="%s"', rowspan)} ${Utils.sprintf(' colspan="%s"', colspan)}>`, formatValue(data[i], i, columns[j]), '</td>')
+              } else {
+                html.push('<td>', formatValue(data[i], i, columns[j]), '</td>')
+              }
             }
           }
         }
 
         html.push('</tr>')
       }
-      html.push('</tbody></table>')
+
+      html.push('</tbody>')
+      if (this.options.showFooter) {
+        html.push('<footer><tr>')
+
+        for (const columns of columnsArray) {
+          for (let h = 0; h < columns.length; h++) {
+            if (!columns[h].printIgnore) {
+              const footerData = Utils.trToData(columns, this.$el.find('>tfoot>tr'))
+              const footerValue = Utils.calculateObjectValue(columns[h], columns[h].footerFormatter, [data], footerData[0] && footerData[0][columns[h].field] || '')
+              html.push(`<th>${footerValue}</th>`)
+            }
+          }
+        }
+
+        html.push('</tr></footer>')
+      }
+      html.push('</table>')
       return html.join('')
     }
 
@@ -162,14 +246,13 @@ $.BootstrapTable = class extends $.BootstrapTable {
       return true
     }
 
-    const filterRows = (data, filters) => data.filter(row => filterRow(row,filters))
-
+    const filterRows = (data, filters) => data.filter(row => filterRow(row, filters))
     const getColumnFilters = columns => !columns || !columns[0] ? [] : columns[0].filter(col => col.printFilter).map(col => ({
       colName: col.field,
       value: col.printFilter
     }))
 
-    data = filterRows(data,getColumnFilters(this.options.columns))
+    data = filterRows(data, getColumnFilters(this.options.columns))
     data = sortRows(data, this.options.printSortColumn, this.options.printSortOrder)
     const table = buildTable(data, this.options.columns)
     const newWin = window.open('')