浏览代码

save the groups within the table data not on the public javascript scope (#4833)

Co-authored-by: Dennis Hernández <dennishernandezvargas@gmail.com>
Dustin Utecht 5 年之前
父节点
当前提交
d204a6b615
共有 1 个文件被更改,包括 3 次插入4 次删除
  1. 3 4
      src/extensions/group-by-v2/bootstrap-table-group-by.js

+ 3 - 4
src/extensions/group-by-v2/bootstrap-table-group-by.js

@@ -4,7 +4,6 @@
  */
 
 let initBodyCaller
-let tableGroups
 
 // it only does '%s', and return '' when arguments are undefined
 const sprintf = function (str) {
@@ -51,7 +50,7 @@ BootstrapTable.prototype.initSort = function (...args) {
   _initSort.apply(this, Array.prototype.slice.apply(args))
 
   const that = this
-  tableGroups = []
+  this.tableGroups = []
 
   if ((this.options.groupBy) && (this.options.groupByField !== '')) {
 
@@ -75,7 +74,7 @@ BootstrapTable.prototype.initSort = function (...args) {
 
     let index = 0
     $.each(groups, (key, value) => {
-      tableGroups.push({
+      this.tableGroups.push({
         id: index,
         name: key,
         data: value
@@ -118,7 +117,7 @@ BootstrapTable.prototype.initBody = function (...args) {
       visibleColumns += 1
     }
 
-    tableGroups.forEach(item => {
+    this.tableGroups.forEach(item => {
       const html = []
 
       html.push(sprintf('<tr class="info groupBy expanded" data-group-index="%s">', item.id))