ソースを参照

Added support for card view and toggle column

Dennis Hernández 10 年 前
コミット
76eaf9fab0
1 ファイル変更42 行追加1 行削除
  1. 42 1
      src/extensions/reorder/bootstrap-table-reorder.js

+ 42 - 1
src/extensions/reorder/bootstrap-table-reorder.js

@@ -21,7 +21,10 @@
     });
     });
 
 
     var BootstrapTable = $.fn.bootstrapTable.Constructor,
     var BootstrapTable = $.fn.bootstrapTable.Constructor,
-        _initHeader = BootstrapTable.prototype.initHeader;
+        _initHeader = BootstrapTable.prototype.initHeader,
+        _toggleColumn = BootstrapTable.prototype.toggleColumn,
+        _toggleView = BootstrapTable.prototype.toggleView,
+        _resetView = BootstrapTable.prototype.resetView;
 
 
     BootstrapTable.prototype.initHeader = function () {
     BootstrapTable.prototype.initHeader = function () {
         _initHeader.apply(this, Array.prototype.slice.apply(arguments));
         _initHeader.apply(this, Array.prototype.slice.apply(arguments));
@@ -33,9 +36,46 @@
         this.makeColumnsReorderable();
         this.makeColumnsReorderable();
     };
     };
 
 
+    BootstrapTable.prototype.toggleColumn = function () {
+        _toggleColumn.apply(this, Array.prototype.slice.apply(arguments));
+
+        if (!this.options.reorderable) {
+            return;
+        }
+
+        this.makeColumnsReorderable();
+    };
+
+    BootstrapTable.prototype.toggleView = function () {
+        _toggleView.apply(this, Array.prototype.slice.apply(arguments));
+
+        if (!this.options.reorderable) {
+            return;
+        }
+
+        if (this.options.cardView) {
+            return;
+        }
+
+        this.makeColumnsReorderable();
+    };
+
+    BootstrapTable.prototype.resetView = function () {
+        _resetView.apply(this, Array.prototype.slice.apply(arguments));
+
+        if (!this.options.reorderable) {
+            return;
+        }
+
+        this.makeColumnsReorderable();
+    };
+
     BootstrapTable.prototype.makeColumnsReorderable = function () {
     BootstrapTable.prototype.makeColumnsReorderable = function () {
 
 
         var that = this;
         var that = this;
+        try {
+            $(this.$el).dragtable('destroy');
+        } catch (e) {}
         $(this.$el).dragtable({
         $(this.$el).dragtable({
             maxMovingRows: that.options.maxMovingRows,
             maxMovingRows: that.options.maxMovingRows,
             clickDelay:200,
             clickDelay:200,
@@ -46,6 +86,7 @@
                 });
                 });
 
 
                 that.header.fields = ths;
                 that.header.fields = ths;
+
                 that.resetView();
                 that.resetView();
                 that.trigger('reorder', ths);
                 that.trigger('reorder', ths);
             }
             }