Browse Source

Fix #1948

Added custom sort function
Example: http://jsfiddle.net/djhvscf/e3nk137y/4595/
Dennis Hernández 10 years ago
parent
commit
f7bce20d09
1 changed files with 9 additions and 1 deletions
  1. 9 1
      src/bootstrap-table.js

+ 9 - 1
src/bootstrap-table.js

@@ -326,6 +326,8 @@
 
 
         customSearch: $.noop,
         customSearch: $.noop,
 
 
+        customSort: $.noop,
+
         rowStyle: function (row, index) {
         rowStyle: function (row, index) {
             return {};
             return {};
         },
         },
@@ -850,6 +852,11 @@
             order = this.options.sortOrder === 'desc' ? -1 : 1,
             order = this.options.sortOrder === 'desc' ? -1 : 1,
             index = $.inArray(this.options.sortName, this.header.fields);
             index = $.inArray(this.options.sortName, this.header.fields);
 
 
+        if (this.options.customSort !== $.noop) {
+            this.options.customSort.apply(this, [this.options.sortName, this.options.sortOrder]);
+            return;
+        }
+
         if (index !== -1) {
         if (index !== -1) {
             this.data.sort(function (a, b) {
             this.data.sort(function (a, b) {
                 if (that.header.sortNames[index]) {
                 if (that.header.sortNames[index]) {
@@ -2802,7 +2809,8 @@
         sprintf: sprintf,
         sprintf: sprintf,
         getFieldIndex: getFieldIndex,
         getFieldIndex: getFieldIndex,
         compareObjects: compareObjects,
         compareObjects: compareObjects,
-        calculateObjectValue: calculateObjectValue
+        calculateObjectValue: calculateObjectValue,
+        getItemField: getItemField
     };
     };
 
 
     // BOOTSTRAP TABLE INIT
     // BOOTSTRAP TABLE INIT