Browse Source

Merge pull request #3120 from rpannell/master

Issue with reorder and master detail
Dennis Hernández 8 years ago
parent
commit
3954c11d04
1 changed files with 14 additions and 13 deletions
  1. 14 13
      src/extensions/reorder-columns/bootstrap-table-reorder-columns.js

+ 14 - 13
src/extensions/reorder-columns/bootstrap-table-reorder-columns.js

@@ -5,13 +5,12 @@
  */
 
 !function ($) {
-
     'use strict';
 
     //From MDN site, https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/filter
     var filterFn = function () {
         if (!Array.prototype.filter) {
-            Array.prototype.filter = function(fun/*, thisArg*/) {
+            Array.prototype.filter = function (fun/*, thisArg*/) {
                 'use strict';
 
                 if (this === void 0 || this === null) {
@@ -113,12 +112,12 @@
         var that = this;
         try {
             $(this.$el).dragtable('destroy');
-        } catch (e) {}
+        } catch (e) { }
         $(this.$el).dragtable({
             maxMovingRows: that.options.maxMovingRows,
             dragaccept: that.options.dragaccept,
-            clickDelay:200,
-            beforeStop: function() {
+            clickDelay: 200,
+            beforeStop: function () {
                 var ths = [],
                     formatters = [],
                     columns = [],
@@ -126,14 +125,16 @@
                     columnIndex = -1,
                     optionsColumns = [];
                 that.$header.find('th').each(function (i) {
-                    ths.push($(this).data('field'));
-                    formatters.push($(this).data('formatter'));
+                    if ($(this).data("field") != undefined) {
+                        ths.push($(this).data('field'));
+                        formatters.push($(this).data('formatter'));
+                    }
                 });
 
                 //Exist columns not shown
                 if (ths.length < that.columns.length) {
                     columnsHidden = $.grep(that.columns, function (column) {
-                       return !column.visible;
+                        return !column.visible;
                     });
                     for (var i = 0; i < columnsHidden.length; i++) {
                         ths.push(columnsHidden[i].field);
@@ -141,7 +142,7 @@
                     }
                 }
 
-                for (var i = 0; i < ths.length; i++ ) {
+                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;
@@ -153,11 +154,11 @@
                 that.columns = that.columns.concat(columns);
 
                 filterFn(); //Support <IE9
-                $.each(that.columns, function(i, column) {
+                $.each(that.columns, function (i, column) {
                     var found = false,
                         field = column.field;
-                    that.options.columns[0].filter(function(item) {
-                        if(!found && item["field"] == field) {
+                    that.options.columns[0].filter(function (item) {
+                        if (!found && item["field"] == field) {
                             optionsColumns.push(item);
                             found = true;
                             return false;
@@ -178,4 +179,4 @@
             }
         });
     };
-}(jQuery);
+}(jQuery);