ソースを参照

Merge pull request #2984 from dizel-by/develop

Multiple Sort extension: added ability to hide UI button and event to force sort after manual data changes
文翼 9 年 前
コミット
0560594fc5

+ 13 - 0
src/extensions/multiple-sort/README.md

@@ -16,6 +16,12 @@ Use Plugin: [bootstrap-table-multiple-sort](https://github.com/dimbslmh/bootstra
 * description: Set true to allow the multiple sort.
 * default: `false`
 
+### showMultiSortButton
+
+* type: Boolean
+* description: Set false to hide multiple sort UI button.
+* default: `true`
+
 ### sortPriority
 
 * type: Object
@@ -27,6 +33,13 @@ Use Plugin: [bootstrap-table-multiple-sort](https://github.com/dimbslmh/bootstra
 * plus: `glyphicon-plus`
 * minus: `glyphicon-minus`
 
+## methods
+
+### multipleSort
+
+* parameters: none
+* description: Force mutltiple sort table (usable after manual data changes).
+
 ## Locales
 
 ### formatMultipleSort

+ 11 - 1
src/extensions/multiple-sort/bootstrap-table-multiple-sort.js

@@ -161,8 +161,11 @@
         }
     };
 
+    $.fn.bootstrapTable.methods.push('multipleSort');
+
     $.extend($.fn.bootstrapTable.defaults, {
         showMultiSort: false,
+        showMultiSortButton: true,
         sortPriority: null,
         onMultipleSort: function() {
             return false;
@@ -240,7 +243,7 @@
             var $btnGroup = this.$toolbar.find('>.btn-group').first(),
                 $multiSortBtn = this.$toolbar.find('div.multi-sort');
 
-            if (!$multiSortBtn.length) {
+            if (!$multiSortBtn.length && this.options.showMultiSortButton) {
                 $multiSortBtn = '  <button class="multi-sort btn btn-default' + (this.options.iconSize === undefined ? '' : ' btn-' + this.options.iconSize) + '" type="button" data-toggle="modal" data-target="' + sortModalId + '" title="' + this.options.formatMultipleSort() + '">';
                 $multiSortBtn += '     <i class="' + this.options.iconsPrefix + ' ' + this.options.icons.sort + '"></i>';
                 $multiSortBtn += '</button>';
@@ -284,6 +287,13 @@
         }
     };
 
+    BootstrapTable.prototype.multipleSort = function() {
+        var that = this;
+        if (!isSingleSort && that.options.sortPriority !== null && typeof that.options.sortPriority === 'object' && that.options.sidePagination !== 'server') {
+            that.onMultipleSort();
+        }
+    };
+
     BootstrapTable.prototype.onMultipleSort = function() {
         var that = this;