Browse Source

Merge pull request #2180 from djhvscf/develop

Some bug fixes
wenzhixin 9 years ago
parent
commit
e3c426b980

+ 1 - 1
src/bootstrap-table.css

@@ -196,7 +196,7 @@
     line-height: 1.428571429;
 }
 
-.fixed-table-toolbar .bars,
+.fixed-table-toolbar .bs-bars,
 .fixed-table-toolbar .search,
 .fixed-table-toolbar .columns {
     position: relative;

+ 5 - 6
src/bootstrap-table.js

@@ -1032,13 +1032,13 @@
             $search,
             switchableCount = 0;
 
-        if (this.$toolbar.find('.bars').children().length) {
+        if (this.$toolbar.find('.bs-bars').children().length) {
             $('body').append($(this.options.toolbar));
         }
         this.$toolbar.html('');
 
         if (typeof this.options.toolbar === 'string' || typeof this.options.toolbar === 'object') {
-            $(sprintf('<div class="bars pull-%s"></div>', this.options.toolbarAlign))
+            $(sprintf('<div class="bs-bars pull-%s"></div>', this.options.toolbarAlign))
                 .appendTo(this.$toolbar)
                 .append($(this.options.toolbar));
         }
@@ -1899,7 +1899,7 @@
         this.trigger('post-body', data);
     };
 
-    BootstrapTable.prototype.initServer = function (silent, query) {
+    BootstrapTable.prototype.initServer = function (silent, query, url) {
         var that = this,
             data = {},
             params = {
@@ -1956,7 +1956,7 @@
         }
         request = $.extend({}, calculateObjectValue(null, this.options.ajaxOptions), {
             type: this.options.method,
-            url: this.options.url,
+            url:  url || this.options.url,
             data: this.options.contentType === 'application/json' && this.options.method === 'post' ?
                 JSON.stringify(data) : data,
             cache: this.options.cache,
@@ -2696,10 +2696,9 @@
 
     BootstrapTable.prototype.refresh = function (params) {
         if (params && params.url) {
-            this.options.url = params.url;
             this.options.pageNumber = 1;
         }
-        this.initServer(params && params.silent, params && params.query);
+        this.initServer(params && params.silent, params && params.query, params && params.url);
         this.trigger('refresh', params);
     };
 

+ 10 - 4
src/extensions/filter-control/bootstrap-table-filter-control.js

@@ -610,6 +610,8 @@
             if (controls.length > 0) {
                 this.filterColumnsPartial = {};
                 $(controls[0]).trigger(controls[0].tagName === 'INPUT' ? 'keyup' : 'change');
+            } else {
+                return;
             }
 
             if (search.length > 0) {
@@ -618,9 +620,11 @@
 
             // use the default sort order if it exists. do nothing if it does not
             if (that.options.sortName !== table.data('sortName') || that.options.sortOrder !== table.data('sortOrder')) {
-                var sorter = sprintf(header.find('[data-field="%s"]', $(controls[0]).closest('table').data('sortName')));
-                that.onSort(table.data('sortName'), table.data('sortName'));
-                $(sorter).find('.sortable').trigger('click');
+                var sorter = header.find(sprintf('[data-field="%s"]', $(controls[0]).closest('table').data('sortName')));
+                if (sorter.length > 0) {
+                    that.onSort(table.data('sortName'), table.data('sortName'));
+                    $(sorter).find('.sortable').trigger('click');
+                }
             }
 
             // clear cookies once the filters are clean
@@ -628,7 +632,9 @@
             timeoutId = setTimeout(function () {
                 if (cookies && cookies.length > 0) {
                     $.each(cookies, function (i, item) {
-                        that.deleteCookie(item);
+                        if (that.deleteCookie !== undefined) {
+                            that.deleteCookie(item);
+                        }
                     });
                 }
             }, that.options.searchTimeOut);

+ 6 - 0
src/extensions/multiple-search/README.md

@@ -15,3 +15,9 @@ Use Plugin: [bootstrap-table-multiple-search](https://github.com/wenzhixin/boots
 * type: Boolean
 * description: Set to true if you want to search by multiple columns. For example: if the user puts: "526 table" we are going to `split` that string and then we are going to search in all columns in the boostrap table.
 * default: `false`
+
+### delimeter
+
+* type: String
+* description: Configure the delimeter of the multiple search
+* default: ` ` (whitespace)

+ 6 - 2
src/extensions/multiple-search/bootstrap-table-multiple-search.js

@@ -9,7 +9,8 @@
     'use strict';
 
     $.extend($.fn.bootstrapTable.defaults, {
-        multipleSearch: false
+        multipleSearch: false,
+	    delimeter: " "
     });
 
     var BootstrapTable = $.fn.bootstrapTable.Constructor,
@@ -17,7 +18,10 @@
 
     BootstrapTable.prototype.initSearch = function () {
         if (this.options.multipleSearch) {
-            var strArray = this.searchText.split(" "),
+            if (this.searchText === undefined) {
+                return;
+            }
+            var strArray = this.searchText.split(this.options.delimeter),
                 that = this,
                 f = $.isEmptyObject(this.filterColumns) ? null : this.filterColumns,
                 dataFiltered = [];

+ 16 - 9
src/extensions/sticky-header/bootstrap-table-sticky-header.js

@@ -20,14 +20,16 @@
         var that = this;
         _initHeader.apply(this, Array.prototype.slice.apply(arguments));
 
-        if (!this.options.stickyHeader) return;
+        if (!this.options.stickyHeader) {
+            return;
+        }
 
-        var table = this.$tableBody.find('table');
-        var table_id = table.attr('id');
-        var header_id = table.attr('id') + '-sticky-header';
-        var sticky_header_container_id = header_id +'-sticky-header-container';
-        var anchor_begin_id = header_id +'_sticky_anchor_begin';
-        var anchor_end_id = header_id +'_sticky_anchor_end';
+        var table = this.$tableBody.find('table'),
+            table_id = table.attr('id'),
+            header_id = table.attr('id') + '-sticky-header',
+            sticky_header_container_id = header_id +'-sticky-header-container',
+            anchor_begin_id = header_id +'_sticky_anchor_begin',
+            anchor_end_id = header_id +'_sticky_anchor_end';
         // add begin and end anchors to track table position
 
         table.before(sprintf('<div id="%s" class="hidden"></div>', sticky_header_container_id));
@@ -38,7 +40,7 @@
 
         // clone header just once, to be used as sticky header
         // deep clone header. using source header affects tbody>td width
-        this.$stickyHeader = $($('#'+header_id).clone());
+        this.$stickyHeader = $($('#'+header_id).clone(true, true));
         // avoid id conflict
         this.$stickyHeader.removeAttr('id');
 
@@ -48,7 +50,12 @@
         // render sticky when table scroll left-right
         table.closest('.fixed-table-container').find('.fixed-table-body').on('scroll.'+table_id, table, match_position_x);
 
-        function render_sticky_header(event){
+        this.$el.on('all.bs.table', function (e) {
+            that.$stickyHeader = $($('#'+header_id).clone(true, true));
+            that.$stickyHeader.removeAttr('id');
+        });
+
+        function render_sticky_header(event) {
             var table = event.data;
             var table_header_id = table.find('thead').attr('id');
             // console.log('render_sticky_header for > '+table_header_id);