Skip to content

Commit

Permalink
Fix wenzhixin#3204: sortName cannot work in server side pagination
Browse files Browse the repository at this point in the history
  • Loading branch information
wenzhixin committed Dec 28, 2017
1 parent 3a42833 commit f1b9a47
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/bootstrap-table.js
Original file line number Diff line number Diff line change
Expand Up @@ -1087,9 +1087,7 @@
if (this.options.rememberOrder) {
this.options.sortOrder = $this.data('order') === 'asc' ? 'desc' : 'asc';
} else {
this.options.sortOrder = this.options.columns[0].filter(function(option) {
return option.field === $this.data('field');
})[0].order;
this.options.sortOrder = this.columns[this.fieldsColumnsIndex[$this.data('field')]].order;
}
}
this.trigger('sort', this.options.sortName, this.options.sortOrder);
Expand Down Expand Up @@ -2063,13 +2061,18 @@
BootstrapTable.prototype.initServer = function (silent, query, url) {
var that = this,
data = {},
index = $.inArray(this.options.sortName, this.header.fields),
params = {
searchText: this.searchText,
sortName: this.options.sortName,
sortOrder: this.options.sortOrder
},
request;

if (this.header.sortNames[index]) {
params.sortName = this.header.sortNames[index];
}

if (this.options.pagination) {
params.pageSize = this.options.pageSize === this.options.formatAllRows() ?
this.options.totalRows : this.options.pageSize;
Expand Down

0 comments on commit f1b9a47

Please sign in to comment.