ソースを参照

Added expandAll and collapseAll methods and

fix #1081 When the data-height is set and we use the group-by extension
and then we open a node the header is not aligned
Dennis Hernández 10 年 前
コミット
1639048ac1

+ 2 - 2
dist/locale/bootstrap-table-fa-IR.js

@@ -1,6 +1,6 @@
 /**
- * Bootstrap Table English translation
- * Author: Zhixin Wen<wenzhixin2010@gmail.com>
+ * Bootstrap Table Persian translation
+ * Author: MJ Vakili <mjv.1989@Gmail.com>
  */
 (function ($) {
     'use strict';

+ 10 - 0
src/extensions/group-by/README.md

@@ -24,6 +24,16 @@ You must include the bootstrap-table-group-by.css file in order to get the appro
 * description: Set the field that you want to group the data.
 * default: ``
 
+## Methods
+
+### expandAll
+
+* Expand all the nodes in the table.
+
+### collapseAll
+
+* Collapse all the nodes in the table.
+
 ## Known issues
 
 ### OnSort

+ 24 - 1
src/extensions/group-by/bootstrap-table-group-by.js

@@ -119,6 +119,11 @@
         originalData: undefined
     });
 
+    $.extend($.fn.bootstrapTable.methods, [
+        'collapseAll',
+        'expandAll'
+    ]);
+
     var BootstrapTable = $.fn.bootstrapTable.Constructor,
         _init = BootstrapTable.prototype.init,
         _initData = BootstrapTable.prototype.initData;
@@ -142,7 +147,17 @@
                 this.options.rowAttributes = rowAttr;
                 this.$el.on('post-body.bs.table', function () {
                     that.$el.treetable({
-                        expandable: true
+                        expandable: true,
+                        onNodeExpand: function () {
+                            if (that.options.height) {
+                                that.resetHeader();
+                            }
+                        },
+                        onNodeCollapse: function () {
+                            if (that.options.height) {
+                                that.resetHeader();
+                            }
+                        }
                     }, true);
                 });
             }
@@ -159,4 +174,12 @@
         }
         _initData.apply(this, Array.prototype.slice.apply(arguments));
     };
+
+    BootstrapTable.prototype.expandAll = function () {
+        this.$el.treetable("expandAll");
+    };
+
+    BootstrapTable.prototype.collapseAll = function () {
+        this.$el.treetable("collapseAll");
+    };
 }(jQuery);

+ 2 - 2
src/locale/bootstrap-table-fa-IR.js

@@ -1,6 +1,6 @@
 /**
- * Bootstrap Table English translation
- * Author: Zhixin Wen<wenzhixin2010@gmail.com>
+ * Bootstrap Table Persian translation
+ * Author: MJ Vakili <mjv.1989@Gmail.com>
  */
 (function ($) {
     'use strict';