From f1b9a47f4df1804b2a7550f53b47fc672edbc1ea Mon Sep 17 00:00:00 2001 From: zhixin Date: Thu, 28 Dec 2017 23:34:57 +0800 Subject: [PATCH] Fix #3204: sortName cannot work in server side pagination --- src/bootstrap-table.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/bootstrap-table.js b/src/bootstrap-table.js index ad3af4d9f2..08ab55d19f 100644 --- a/src/bootstrap-table.js +++ b/src/bootstrap-table.js @@ -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); @@ -2063,6 +2061,7 @@ 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, @@ -2070,6 +2069,10 @@ }, 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;