8000 Merge pull request #2180 from djhvscf/develop · chavp/bootstrap-table@e3c426b · GitHub
[go: up one dir, main page]

Skip to content

Commit e3c426b

Browse files
committed
Merge pull request wenzhixin#2180 from djhvscf/develop
Some bug fixes
2 parents a631aea + e65c6e6 commit e3c426b

File tree

6 files changed

+44
-22
lines changed

6 files changed

+44
-22
lines changed

src/bootstrap-table.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@
196196
line-height: 1.428571429;
197197
}
198198

199-
.fixed-table-toolbar .bars,
199+
.fixed-table-toolbar .bs-bars,
200200
.fixed-table-toolbar .search,
201201
.fixed-table-toolbar .columns {
202202
position: relative;

src/bootstrap-table.js

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1032,13 +1032,13 @@
10321032
$search,
10331033
switchableCount = 0;
10341034

1035-
if (this.$toolbar.find('.bars').children().length) {
1035+
if (this.$toolbar.find('.bs-bars').children().length) {
10361036
$('body').append($(this.options.toolbar));
10371037
}
10381038
this.$toolbar.html('');
10391039

10401040
if (typeof this.options.toolbar === 'string' || typeof this.options.toolbar === 'object') {
1041-
$(sprintf('<div class="bars pull-%s"></div>', this.options.toolbarAlign))
1041+
$(sprintf('<div class="bs-bars pull-%s"></div>', this.options.toolbarAlign))
10421042
.appendTo(this.$toolbar)
10431043
.append($(this.options.toolbar));
10441044
}
@@ -1899,7 +1899,7 @@
18991899
this.trigger('post-body', data);
19001900
};
19011901

1902-
BootstrapTable.prototype.initServer = function (silent, query) {
1902+
BootstrapTable.prototype.initServer = function (silent, query, url) {
19031903
var that = this,
19041904
data = {},
19051905
params = {
@@ -1956,7 +1956,7 @@
19561956
}
19571957
request = $.extend({}, calculateObjectValue(null, this.options.ajaxOptions), {
19581958
type: this.options.method,
1959-
url: this.options.url,
1959+
url: url || this.options.url,
19601960
data: this.options.contentType === 'application/json' && this.options.method === 'post' ?
19611961
JSON.stringify(data) : data,
19621962
cache: this.options.cache,
@@ -2696,10 +2696,9 @@
26962696

26972697
BootstrapTable.prototype.refresh = function (params) {
26982698
if (params && params.url) {
2699-
this.options.url = params.url;
27002699
this.options.pageNumber = 1;
27012700
}
2702-
this.initServer(params && params.silent, params && params.query);
2701+
this.initServer(params && params.silent, params && params.query, params && params.url);
27032702
this.trigger('refresh', params);
27042703
};
27052704

src/extensions/filter-control/bootstrap-table-filter-control.js

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -610,6 +610,8 @@
610610
if (controls.length > 0) {
611611
this.filterColumnsPartial = {};
612612
$(controls[0]).trigger(controls[0].tagName === 'INPUT' ? 'keyup' : 'change');
613+
} else {
614+
return;
613615
}
614616

615617
if (search.length > 0) {
@@ -618,17 +620,21 @@
618620

619621
// use the default sort order if it exists. do nothing if it does not
620622
if (that.options.sortName !== table.data('sortName') || that.options.sortOrder !== table.data('sortOrder')) {
621-
var sorter = sprintf(header.find('[data-field="%s"]', $(controls[0]).closest('table').data('sortName')));
622-
that.onSort(table.data('sortName'), table.data('sortName'));
623-
$(sorter).find('.sortable').trigger('click');
623+
var sorter = header.find(sprintf('[data-field="%s"]', $(controls[0]).closest('table').data('sortName')));
624+
if (sorter.length > 0) {
625+
that.onSort(table.data('sortName'), table.data('sortName'));
626+
$(sorter).find('.sortable').trigger('click');
627+
}
624628
}
625629

626630
// clear cookies once the filters are clean
627631
clearTimeout(timeoutId);
628632
timeoutId = setTimeout(function () {
629633
if (cookies && cookies.length > 0) {
630634
$.each(cookies, function (i, item) {
631-
that.deleteCookie(item);
635+
if (that.deleteCookie !== undefined) {
636+
that.deleteCookie(item);
637+
}
632638
});
633639
}
634640
}, that.options.searchTimeOut);

src/extensions/multiple-search/README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,9 @@ Use Plugin: [bootstrap-table-multiple-search](https://github.com/wenzhixin/boots
1515
* type: Boolean
1616
* 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.
1717
* default: `false`
18+
19+
### delimeter
20+
21+
* type: String
22+
* description: Configure the delimeter of the multiple search
23+
* default: ` ` (whitespace)

src/extensions/multiple-search/bootstrap-table-multiple-search.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,19 @@
99
'use strict';
1010

1111
$.extend($.fn.bootstrapTable.defaults, {
12-
multipleSearch: false
12+
multipleSearch: false,
13+
delimeter: " "
1314
});
1415

1516
var BootstrapTable = $.fn.bootstrapTable.Constructor,
1617
_initSearch = BootstrapTable.prototype.initSearch;
1718

1819
BootstrapTable.prototype.initSearch = function () {
1920
if (this.options.multipleSearch) {
20-
var strArray = this.searchText.split(" "),
21+
if (this.searchText === undefined) {
22+
return;
23+
}
24+
var strArray = this.searchText.split(this.options.delimeter),
2125
that = this,
2226
f = $.isEmptyObject(this.filterColumns) ? null : this.filterColumns,
2327
dataFiltered = [];

src/extensions/sticky-header/bootstrap-table-sticky-header.js

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,16 @@
2020
var that = this;
2121
_initHeader.apply(this, Array.prototype.slice.apply(arguments));
2222

23-
if (!this.options.stickyHeader) return;
23+
if (!this.options.stickyHeader) {
24+
return;
25+
}
2426

25-
var table = this.$tableBody.find('table');
26-
var table_id = table.attr('id');
27-
var header_id = table.attr('id') + '-sticky-header';
28-
var sticky_header_container_id = header_id +'-sticky-header-container';
29-
var anchor_begin_id = header_id +'_sticky_anchor_begin';
30-
var anchor_end_id = header_id +'_sticky_anchor_end';
27+
var table = this.$tableBody.find('table'),
28+
table_id = table.attr('id'),
29+
header_id = table.attr('id') + '-sticky-header',
30+
sticky_header_container_id = header_id +'-sticky-header-container',
31+
anchor_begin_id = header_id +'_sticky_anchor_begin',
32+
anchor_end_id = header_id +'_sticky_anchor_end';
3133
// add begin and end anchors to track table position
3234

3335
table.before(sprintf('<div id="%s" class="hidden"></div>', sticky_header_container_id));
@@ -38,7 +40,7 @@
3840

3941
// clone header just once, to be used as sticky header
4042
// deep clone header. using source header affects tbody>td width
41-
this.$stickyHeader = $($('#'+header_id).clone());
43+
this.$stickyHeader = $($('#'+header_id).clone(true, true));
4244
// avoid id conflict
4345
this.$stickyHeader.removeAttr('id');
4446

@@ -48,7 +50,12 @@
4850
// render sticky when table scroll left-right
4951
table.closest('.fixed-table-container').find('.fixed-table-body').on('scroll.'+table_id, table, match_position_x);
5052

51-
function render_sticky_header(event){
53+
this.$el.on('all.bs.table', function (e) {
54+
that.$stickyHeader = $($('#'+header_id).clone(true, true));
55+
that.$stickyHeader.removeAttr('id');
56+
});
57+
58+
function render_sticky_header(event) {
5259
var table = event.data;
5360
var table_header_id = table.find('thead').attr('id');
5461
// console.log('render_sticky_header for > '+table_header_id);

0 commit comments

Comments
 (0)
0