Browse Source

After reordering columns, reinitialise the toolbar (#2330)

* After reordering columns, reinitialise the toolbar

If you reorder the columns, and then try to hide/show some columns, you will encounter that the wrong columns are hidden/shown, because the order change has not been notified to the toolbar.

* After reordering columns, update the fieldIndex
Ignacio Huerta 8 years ago
parent
commit
b18c05f0d8
1 changed files with 4 additions and 0 deletions
  1. 4 0
      src/extensions/reorder-columns/bootstrap-table-reorder-columns.js

+ 4 - 0
src/extensions/reorder-columns/bootstrap-table-reorder-columns.js

@@ -144,6 +144,7 @@
                 for (var i = 0; i < ths.length; i++ ) {
                     columnIndex = $.fn.bootstrapTable.utils.getFieldIndex(that.columns, ths[i]);
                     if (columnIndex !== -1) {
+                        that.columns[columnIndex].fieldIndex = i;
                         columns.push(that.columns[columnIndex]);
                         that.columns.splice(columnIndex, 1);
                     }
@@ -169,6 +170,9 @@
 
                 that.header.fields = ths;
                 that.header.formatters = formatters;
+                that.initHeader();
+                that.initToolbar();
+                that.initBody();
                 that.resetView();
                 that.trigger('reorder-column', ths);
             }