Browse Source

Merge pull request #837 from djhvscf/master

Fix #834
文翼 10 years ago
parent
commit
7009e8cc07

+ 17 - 1
docs/_i18n/en/documentation/methods.md

@@ -36,7 +36,7 @@ The calling method syntax: `$('#table').bootstrapTable('method', parameter);`.
     <tr>
         <td>getData</td>
         <td>useCurrentPage</td>
-        <td>Get the loaded data of table. If you set the useCurrentPage to true the method will return the data in the current page</td>
+        <td>Get the loaded data of table at the moment that this method is called. If you set the useCurrentPage to true the method will return the data in the current page</td>
     </tr>
     <tr>
         <td>load</td>
@@ -64,6 +64,22 @@ The calling method syntax: `$('#table').bootstrapTable('method', parameter);`.
         </td>
     </tr>
     <tr>
+        <td>removeAll</td>
+        <td>-</td>
+        <td>
+        Remove all data from table<br>
+        Example: $('#myTable').bootstrapTable('removeAll')
+        </td>
+    </tr>
+    <tr>
+        <td>removeByUniqueId</td>
+        <td>id</td>
+        <td>
+        Remove data from table, the row that contains the id passed by parameter<br>
+        Example: $('#myTable').bootstrapTable('removeByUniqueId', "122")
+        </td>
+    </tr>
+    <tr>
         <td>insertRow</td>
         <td>params</td>
         <td>

+ 3 - 3
docs/_i18n/en/extensions/reorder.md

@@ -11,12 +11,12 @@ Dependence: [dragTable](https://github.com/akottr/dragtable/) v2.0.14 (must incl
 <link rel="stylesheet" href=".../dragtable.css">
 <script src=".../jquery-ui.js"></script>
 <script src=".../jquery.dragtable.js"></script>
-<script src="extensions/cookie/bootstrap-table-reorder.js"></script>
+<script src="extensions/cookie/bootstrap-table-reorder-columns.js"></script>
 ```
 
 ## Options
 
-### reorderable
+### reorderableColumns
 
 * type: Boolean
 * description: Set true to allow the reorder feature.
@@ -30,6 +30,6 @@ Dependence: [dragTable](https://github.com/akottr/dragtable/) v2.0.14 (must incl
 
 ## Events
 
-### onReorder(reorder.bs.table)
+### onReorderColumn(reorder-column.bs.table)
 
 Fired when the column was dropped, receive as parameter the new header fields order

+ 1 - 1
docs/_i18n/es.yml

@@ -1,6 +1,6 @@
 pages:
   getting_started:
-    title: "Empezando con Bootstrap-table"
+    title: "Iniciar con Bootstrap-table"
     lead: "Una visión de Bootstrap Table, cómo descargarlo, usarlo, templates básicos, y más."
   examples:
     title: "Ejemplos"

+ 17 - 1
docs/_i18n/es/documentation/methods.md

@@ -31,7 +31,7 @@ Sintaxis para llamar a un método: `$('#table').bootstrapTable('method', paramet
     <tr>
         <td>getData</td>
         <td>useCurrentPage</td>
-        <td>Retorna los datos cargados en la tabla. Si se setea useCurrentPage a true se devolverá los datos mostrados en la página
+        <td>Retorna los datos cargados en la tabla en el momento que se llama este método. Si se setea useCurrentPage a true se devolverá los datos mostrados en la página
         actual</td>
     </tr>
     <tr>
@@ -60,6 +60,22 @@ Sintaxis para llamar a un método: `$('#table').bootstrapTable('method', paramet
         </td>
     </tr>
     <tr>
+        <td>removeAll</td>
+        <td>-</td>
+        <td>
+        Se remueven todos los datos de la tabla <br>
+        Ejemplo: $('#myTable').bootstrapTable('removeAll')
+        </td>
+    </tr>
+    <tr>
+        <td>removeByUniqueId</td>
+        <td>id</td>
+        <td>
+        Se remueve el dato de la tabla que contiene el id pasado por parámetro<br>
+        Ejemplo: $('#myTable').bootstrapTable('removeByUniqueId', "122")
+        </td>
+    </tr>
+    <tr>
         <td>insertRow</td>
         <td>params</td>
         <td>

+ 3 - 3
docs/_i18n/es/extensions/reorder.md

@@ -11,12 +11,12 @@ Dependence: [dragTable](https://github.com/akottr/dragtable/) v2.0.14 (must incl
 <link rel="stylesheet" href=".../dragtable.css">
 <script src=".../jquery-ui.js"></script>
 <script src=".../jquery.dragtable.js"></script>
-<script src="extensions/cookie/bootstrap-table-reorder.js"></script>
+<script src="extensions/cookie/bootstrap-table-reorder-columns.js"></script>
 ```
 
 ## Options
 
-### reorderable
+### reorderableColumns
 
 * type: Boolean
 * description: Set true to allow the reorder feature.
@@ -30,6 +30,6 @@ Dependence: [dragTable](https://github.com/akottr/dragtable/) v2.0.14 (must incl
 
 ## Events
 
-### onReorder(reorder.bs.table)
+### onReorderColumn(reorder-column.bs.table)
 
 Fired when the column was dropped, receive as parameter the new header fields order

+ 3 - 3
docs/_i18n/zh-cn/extensions/reorder.md

@@ -11,12 +11,12 @@ Dependence: [dragTable](https://github.com/akottr/dragtable/) v2.0.14 (must incl
 <link rel="stylesheet" href=".../dragtable.css">
 <script src=".../jquery-ui.js"></script>
 <script src=".../jquery.dragtable.js"></script>
-<script src="extensions/cookie/bootstrap-table-reorder.js"></script>
+<script src="extensions/cookie/bootstrap-table-reorder-columns.js"></script>
 ```
 
 ## Options
 
-### reorderable
+### reorderableColumns
 
 * type: Boolean
 * description: Set true to allow the reorder feature.
@@ -30,6 +30,6 @@ Dependence: [dragTable](https://github.com/akottr/dragtable/) v2.0.14 (must incl
 
 ## Events
 
-### onReorder(reorder.bs.table)
+### onReorderColumn(reorder-column.bs.table)
 
 Fired when the column was dropped, receive as parameter the new header fields order

+ 94 - 10
src/bootstrap-table.js

@@ -66,6 +66,7 @@
         });
         return index;
     };
+
     var getScrollBarWidth = function () {
         if (cachedWidth === null) {
             var inner = $('<p/>').addClass('fixed-table-scroll-inner'),
@@ -134,6 +135,18 @@
         return height;
     };
 
+    var getRealDataAttr = function (dataAttr) {
+        for (var attr in dataAttr) {
+            var auxAttr = attr.split(/(?=[A-Z])/).join('-').toLowerCase();
+            if (auxAttr !== attr) {
+                dataAttr[auxAttr] = dataAttr[attr];
+                delete dataAttr[attr];
+            }
+        }
+
+        return dataAttr;
+    };
+
     // BOOTSTRAP TABLE CLASS DEFINITION
     // ======================
 
@@ -276,6 +289,12 @@
         },
         onPostHeader: function () {
             return false;
+        },
+        onPreRows: function () {
+            return false;
+        },
+        onPostRows: function () {
+            return false;
         }
     };
 
@@ -360,7 +379,9 @@
         'toggle.bs.table': 'onToggle',
         'pre-body.bs.table': 'onPreBody',
         'post-body.bs.table': 'onPostBody',
-        'post-header.bs.table': 'onPostHeader'
+        'post-header.bs.table': 'onPostHeader',
+        'pre-rows.bs.table': 'onPreRows',
+        'post-rows.bs.table': 'onPostRows'
     };
 
     BootstrapTable.prototype.init = function () {
@@ -426,7 +447,7 @@
             var column = $.extend({}, {
                 title: $(this).html(),
                 'class': $(this).attr('class')
-            }, $(this).data());
+            }, getRealDataAttr($(this).data()));
 
             columns.push(column);
         });
@@ -447,7 +468,7 @@
             // save tr's id, class and data-* attributes
             row._id = $(this).attr('id');
             row._class = $(this).attr('class');
-            row._data = $(this).data();
+            row._data = getRealDataAttr($(this).data());
 
             $(this).find('td').each(function (i) {
                 var field = that.options.columns[i].field;
@@ -456,7 +477,8 @@
                 // save td's id, class and data-* attributes
                 row['_' + field + '_id'] = $(this).attr('id');
                 row['_' + field + '_class'] = $(this).attr('class');
-                row['_' + field + '_data'] = $(this).data();
+                row['_' + field + '_rowspan'] = $(this).attr('rowspan');
+                row['_' + field + '_data'] = getRealDataAttr($(this).data());
             });
             data.push(row);
         });
@@ -615,7 +637,15 @@
         } else {
             this.data = data || this.options.data;
         }
-        this.options.data = this.data;
+
+        // Fix #839 Records deleted when adding new row on filtered table
+        if (type === 'append') {
+            this.options.data = this.options.data.concat(data);
+        } else if (type === 'prepend') {
+            this.options.data = [].concat(data).concat(this.options.data);
+        } else {
+            this.options.data = this.data;
+        }
 
         if (this.options.sidePagination === 'server') {
             return;
@@ -1218,6 +1248,7 @@
                     id_ = '',
                     class_ = that.header.classes[j],
                     data_ = '',
+                    rowspan_ = '',
                     column = that.options.columns[getFieldIndex(that.options.columns, field)];
 
                 style = sprintf('style="%s"', csses.concat(that.header.styles[j]).join('; '));
@@ -1232,6 +1263,9 @@
                 if (item['_' + field + '_class']) {
                     class_ = sprintf(' class="%s"', item['_' + field + '_class']);
                 }
+                if (item['_' + field + '_rowspan']) {
+                    rowspan_ = sprintf(' rowspan="%s"', item['_' + field + '_rowspan']);
+                }
                 cellStyle = calculateObjectValue(that.header,
                     that.header.cellStyles[j], [value, item, i], cellStyle);
                 if (cellStyle.classes) {
@@ -1284,7 +1318,7 @@
                                 getPropertyFromOther(that.options.columns, 'field', 'title', field)) : '',
                             sprintf('<span class="value">%s</span>', value),
                             '</div>'].join('') :
-                        [sprintf('<td%s %s %s %s>', id_, class_, style, data_),
+                        [sprintf('<td%s %s %s %s %s>', id_, class_, style, data_, rowspan_),
                             value,
                             '</td>'].join('');
 
@@ -1311,7 +1345,10 @@
                 '</tr>');
         }
 
+        this.trigger('pre-rows');
         this.$body.html(html.join(''));
+        this.trigger('post-rows');
+
 
         if (!fixedScroll) {
             this.scrollTo(0);
@@ -1341,7 +1378,6 @@
                 row = that.data[$(this).data('index')];
 
             row[that.header.stateField] = checked;
-            that.trigger(checked ? 'check' : 'uncheck', row);
 
             if (that.options.singleSelect) {
                 that.$selectItem.not(this).each(function () {
@@ -1351,6 +1387,7 @@
             }
 
             that.updateSelected();
+            that.trigger(checked ? 'check' : 'uncheck', row);
         });
 
         $.each(this.header.events, function (i, events) {
@@ -1789,6 +1826,51 @@
         this.initBody(true);
     };
 
+    BootstrapTable.prototype.removeAll = function () {
+        if (this.options.data.length > 0) {
+            this.options.data.splice(0, this.options.data.length);
+            this.initSearch();
+            this.initPagination();
+            this.initBody(true);
+        }
+    };
+
+    BootstrapTable.prototype.removeByUniqueId = function (id) {
+        var uniqueId = this.options.uniqueId,
+            len = this.options.data.length,
+            i, row;
+
+        for (i = len - 1; i >= 0; i--) {
+            row = this.options.data[i];
+
+            if (!row.hasOwnProperty(uniqueId)) {
+                continue;
+            }
+
+            if (typeof row[uniqueId] === 'string') {
+                id = id.toString();
+            } else if (typeof row[uniqueId] === 'number') {
+                if ((Number(row[uniqueId]) === row[uniqueId]) && (row[uniqueId] % 1 === 0)) {
+                    id = parseInt(id);
+                } else if ((row[uniqueId] === Number(row[uniqueId])) && (row[uniqueId] !== 0)) {
+                    id = parseFloat(id);
+                }
+            }
+
+            if (row[uniqueId] === id) {
+                this.options.data.splice(i, 1);
+            }
+        }
+
+        if (len === this.options.data.length) {
+            return;
+        }
+
+        this.initSearch();
+        this.initPagination();
+        this.initBody(true);
+    };
+
     BootstrapTable.prototype.insertRow = function (params) {
         if (!params.hasOwnProperty('index') || !params.hasOwnProperty('row')) {
             return;
@@ -1796,6 +1878,7 @@
         this.data.splice(params.index, 0, params.row);
         this.initSearch();
         this.initPagination();
+        this.initSort();
         this.initBody(true);
     };
 
@@ -1804,6 +1887,7 @@
             return;
         }
         $.extend(this.data[params.index], params.row);
+        this.initSort();
         this.initBody(true);
     };
 
@@ -1832,7 +1916,7 @@
             }
         }
         return rows;
-    }
+    };
 
     BootstrapTable.prototype.mergeCells = function (options) {
         var row = options.index,
@@ -2054,8 +2138,8 @@
     var allowedMethods = [
         'getOptions',
         'getSelections', 'getAllSelections', 'getData',
-        'load', 'append', 'prepend', 'remove',
-        'insertRow', 'updateRow',
+        'load', 'append', 'prepend', 'remove', 'removeAll',
+        'insertRow', 'updateRow', 'removeByUniqueId',
         'showRow', 'hideRow', 'getRowsHidden',
         'mergeCells',
         'checkAll', 'uncheckAll',

+ 0 - 2
src/extensions/keyevents/bootstrap-table-keyevents.js

@@ -23,7 +23,6 @@
         this.initKeyEvents();
     };
 
-
     BootstrapTable.prototype.initKeyEvents = function () {
         if (this.options.keyEvents) {
             var that = this;
@@ -79,5 +78,4 @@
             });
         }
     };
-
 }(jQuery);

+ 5 - 5
src/extensions/reorder/README.md

@@ -1,6 +1,6 @@
-# Table Reorder
+# Table Reorder Columns
 
-Use Plugin: [bootstrap-table-reorder](https://github.com/wenzhixin/bootstrap-table/tree/master/src/extensions/reorder) </br>
+Use Plugin: [bootstrap-table-reorder-columns](https://github.com/wenzhixin/bootstrap-table/tree/master/src/extensions/reordercolumns) </br>
 Dependence: [dragTable](https://github.com/akottr/dragtable/) v2.0.14 (must include the css file), </br>
 [jquery-ui](https://code.jquery.com/ui/) v1.11
 
@@ -11,12 +11,12 @@ Dependence: [dragTable](https://github.com/akottr/dragtable/) v2.0.14 (must incl
 <link rel="stylesheet" href=".../dragtable.css">
 <script src=".../jquery-ui.js"></script>
 <script src=".../jquery.dragtable.js"></script>
-<script src="extensions/cookie/bootstrap-table-reorder.js"></script>
+<script src="extensions/reordercolumns/bootstrap-table-reorder-columns.js"></script>
 ```
 
 ## Options
 
-### reorderable
+### reorderableColumns
 
 * type: Boolean
 * description: Set true to allow the reorder feature.
@@ -30,6 +30,6 @@ Dependence: [dragTable](https://github.com/akottr/dragtable/) v2.0.14 (must incl
 
 ## Events
 
-### onReorder(reorder.bs.table)
+### onReorderColumn(reorder-column.bs.table)
 
 Fired when the column was dropped, receive as parameter the new header fields order

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

@@ -22,15 +22,15 @@
     };
 
     $.extend($.fn.bootstrapTable.defaults, {
-        reorderable: false,
+        reorderableColumns: false,
         maxMovingRows: 10,
-        onReorder: function (headerFields) {
+        onReorderColumn: function (headerFields) {
             return false;
         }
     });
 
     $.extend($.fn.bootstrapTable.Constructor.EVENTS, {
-        'reorder.bs.table': 'onReorder'
+        'reorder-column.bs.table': 'onReorderColumn'
     });
 
     var BootstrapTable = $.fn.bootstrapTable.Constructor,
@@ -42,27 +42,27 @@
     BootstrapTable.prototype.initHeader = function () {
         _initHeader.apply(this, Array.prototype.slice.apply(arguments));
 
-        if (!this.options.reorderable) {
+        if (!this.options.reorderableColumns) {
             return;
         }
 
-        this.makeColumnsReorderable();
+        this.makeRowsReorderable();
     };
 
     BootstrapTable.prototype.toggleColumn = function () {
         _toggleColumn.apply(this, Array.prototype.slice.apply(arguments));
 
-        if (!this.options.reorderable) {
+        if (!this.options.reorderableColumns) {
             return;
         }
 
-        this.makeColumnsReorderable();
+        this.makeRowsReorderable();
     };
 
     BootstrapTable.prototype.toggleView = function () {
         _toggleView.apply(this, Array.prototype.slice.apply(arguments));
 
-        if (!this.options.reorderable) {
+        if (!this.options.reorderableColumns) {
             return;
         }
 
@@ -70,20 +70,20 @@
             return;
         }
 
-        this.makeColumnsReorderable();
+        this.makeRowsReorderable();
     };
 
     BootstrapTable.prototype.resetView = function () {
         _resetView.apply(this, Array.prototype.slice.apply(arguments));
 
-        if (!this.options.reorderable) {
+        if (!this.options.reorderableColumns) {
             return;
         }
 
-        this.makeColumnsReorderable();
+        this.makeRowsReorderable();
     };
 
-    BootstrapTable.prototype.makeColumnsReorderable = function () {
+    BootstrapTable.prototype.makeRowsReorderable = function () {
 
         var that = this;
         try {
@@ -111,7 +111,7 @@
                 that.options.columns = that.options.columns.concat(columns);
                 that.header.fields = ths;
                 that.resetView();
-                that.trigger('reorder', ths);
+                that.trigger('reorder-column', ths);
             }
         });
     };

+ 74 - 0
src/extensions/reorderrows/README.md

@@ -0,0 +1,74 @@
+# Table Reorder Rows
+
+Use Plugin: [bootstrap-table-reorder-rows](https://github.com/wenzhixin/bootstrap-table/tree/master/src/extensions/reorderrows) </br>
+Dependence: [tablednd](https://github.com/isocra/TableDnD) v0.9, </br>
+if you want you can include the bootstrap-table-reorder-rows.css file to use the default dragClass
+
+
+## Usage
+
+```html
+<link rel="stylesheet" href=".../bootstrap-table-reorder-rows.css">
+<script src=".../jquery.tablednd.js"></script>
+<script src="extensions/reorderrows/bootstrap-table-reorder-rows.js"></script>
+```
+
+## Options
+
+### reorderableRows
+
+* type: Boolean
+* description: Set true to allow the reorder feature.
+* default: `false`
+
+### onDragStyle
+
+* type: String
+* description: This is the style that is assigned to the row during drag. There are limitations to the styles that can be associated with a row (such as you can't assign a border—well you can, but it won't be displayed).
+* default: `null`
+
+### onDropStyle
+
+* type: String
+* description: This is the style that is assigned to the row when it is dropped. As for onDragStyle, there are limitations to what you can do. Also this replaces the original style, so again consider using onDragClass which is simply added and then removed on drop.
+* default: `null`
+
+### onDragClass
+
+* type: String
+* description: This class is added for the duration of the drag and then removed when the row is dropped. It is more flexible than using onDragStyle since it can be inherited by the row cells and other content.
+* default: `reorder_rows_onDragClass`
+
+### dragHandle
+
+* type: String
+* description: This is the cursor to use
+* default: `null`
+
+### useRowAttrFunc
+
+* type: Boolean
+* description: This function must be use if your `tr` elements won't have the `id` attribute. If your `tr` elements don't have the `id` attribute this plugin don't fire the onDrop event.
+* default: `false`
+
+### onReorderRowsDrag
+
+* type: Function
+* description: Pass a function that will be called when the user starts dragging. The function takes 2 parameters: the table and the row which the user has started to drag.
+* default: `empty function`
+
+### onReorderRowsDrop
+
+* type: Function
+* description: Pass a function that will be called when the row is dropped. The function takes 2 parameters: the table and the row that was dropped.
+* default: `empty function`
+
+## Events
+
+### onReorderRow(reorder-row.bs.table)
+
+Fired when the row was dropped, receive as parameter the new data order
+
+## The existing problems
+
+* After search if the user reorder the rows the data is not shown properly after that.

+ 14 - 0
src/extensions/reorderrows/bootstrap-table-reorder-rows.css

@@ -0,0 +1,14 @@
+.reorder_rows_onDragClass td {
+    background-color: #eee;
+    -webkit-box-shadow: 11px 5px 12px 2px #333, 0 1px 0 #ccc inset, 0 -1px 0 #ccc inset;
+    -webkit-box-shadow: 6px 3px 5px #555, 0 1px 0 #ccc inset, 0 -1px 0 #ccc inset;
+    -moz-box-shadow: 6px 4px 5px 1px #555, 0 1px 0 #ccc inset, 0 -1px 0 #ccc inset;
+    -box-shadow: 6px 4px 5px 1px #555, 0 1px 0 #ccc inset, 0 -1px 0 #ccc inset;
+}
+
+.reorder_rows_onDragClass td:last-child {
+    -webkit-box-shadow: 8px 7px 12px 0 #333, 0 1px 0 #ccc inset, 0 -1px 0 #ccc inset;
+    -webkit-box-shadow: 1px 8px 6px -4px #555, 0 1px 0 #ccc inset, 0 -1px 0 #ccc inset;
+    -moz-box-shadow: 0 9px 4px -4px #555, 0 1px 0 #ccc inset, 0 -1px 0 #ccc inset, -1px 0 0 #ccc inset;
+    -box-shadow: 0 9px 4px -4px #555, 0 1px 0 #ccc inset, 0 -1px 0 #ccc inset, -1px 0 0 #ccc inset;
+}

+ 115 - 0
src/extensions/reorderrows/bootstrap-table-reorder-rows.js

@@ -0,0 +1,115 @@
+/**
+ * @author: Dennis Hernández
+ * @webSite: http://djhvscf.github.io/Blog
+ * @version: v1.0.0
+ */
+
+!function ($) {
+
+    'use strict';
+
+    var isSearch = false;
+
+    var rowAttr = function (row, index) {
+        return {
+            id: 'customId_' + index
+        };
+    };
+
+    $.extend($.fn.bootstrapTable.defaults, {
+        reorderableRows: false,
+        onDragStyle: null,
+        onDropStyle: null,
+        onDragClass: "reorder_rows_onDragClass",
+        dragHandle: null,
+        useRowAttrFunc: false,
+        onReorderRowsDrag: function (table, row) {
+            return false;
+        },
+        onReorderRowsDrop: function (table, row) {
+            return false;
+        },
+        onReorderRow: function (newData) {
+             return false;
+        }
+    });
+
+    $.extend($.fn.bootstrapTable.Constructor.EVENTS, {
+        'reorder-row.bs.table': 'onReorderRow'
+    });
+
+    var BootstrapTable = $.fn.bootstrapTable.Constructor,
+        _init = BootstrapTable.prototype.init,
+        _initSearch = BootstrapTable.prototype.initSearch;
+
+    BootstrapTable.prototype.init = function () {
+
+        _init.apply(this, Array.prototype.slice.apply(arguments));
+
+        if (!this.options.reorderableRows) {
+            return;
+        }
+
+        var that = this;
+        if (this.options.useRowAttrFunc) {
+            this.options.rowAttributes = rowAttr;
+        }
+
+        var onPostRows = this.options.onPostRows;
+        this.options.onPostRows = function () {
+            setTimeout(function () {
+                that.makeRowsReorderable();
+                onPostRows.apply();
+            }, 1);
+        };
+    };
+
+    BootstrapTable.prototype.initSearch = function () {
+        _initSearch.apply(this, Array.prototype.slice.apply(arguments));
+
+        if (!this.options.reorderableRows) {
+            return;
+        }
+
+        //Known issue after search if you reorder the rows the data is not display properly
+        //isSearch = true;
+    };
+
+    BootstrapTable.prototype.makeRowsReorderable = function () {
+        if (this.options.cardView) {
+            return;
+        }
+
+        var that = this;
+        this.$el.tableDnD({
+            onDragStyle: that.options.onDragStyle,
+            onDropStyle: that.options.onDropStyle,
+            onDragClass: that.options.onDragClass,
+            onDrop: that.onDrop,
+            onDragStart: that.options.onReorderRowsDrag,
+            dragHandle: that.options.dragHandle
+        });
+    };
+
+    BootstrapTable.prototype.onDrop = function (table, row) {
+        var tableBs = $(table),
+            tableBsData = tableBs.data('bootstrap.table'),
+            tableBsOptions = tableBs.data('bootstrap.table').options,
+            row = null,
+            newData = [];
+
+        for (var i = 0; i < table.tBodies[0].rows.length; i++) {
+            row = $(table.tBodies[0].rows[i]);
+            newData.push(tableBsOptions.data[row.data('index')]);
+            row.data('index', i).attr('data-index', i);
+        }
+
+        tableBsOptions.data = newData;
+
+        //Call the user defined function
+        tableBsOptions.onReorderRowsDrop.apply(table, row);
+
+        //Call the event reorder-row
+        tableBsData.trigger('reorder-row', newData);
+    };
+}(jQuery);