|
@@ -530,6 +530,12 @@ class BootstrapTable {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ sortBy (params) {
|
|
|
|
|
+ this.options.sortName = params.field
|
|
|
|
|
+ this.options.sortOrder = params.hasOwnProperty('sortOrder') ? params.sortOrder : 'asc'
|
|
|
|
|
+ this._sort()
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
onSort ({ type, currentTarget }) {
|
|
onSort ({ type, currentTarget }) {
|
|
|
const $this = type === 'keypress' ? $(currentTarget) : $(currentTarget).parent()
|
|
const $this = type === 'keypress' ? $(currentTarget) : $(currentTarget).parent()
|
|
|
const $this_ = this.$header.find('th').eq($this.index())
|
|
const $this_ = this.$header.find('th').eq($this.index())
|
|
@@ -561,13 +567,18 @@ class BootstrapTable {
|
|
|
this.columns[this.fieldsColumnsIndex[$this.data('field')]].order
|
|
this.columns[this.fieldsColumnsIndex[$this.data('field')]].order
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
- this.trigger('sort', this.options.sortName, this.options.sortOrder)
|
|
|
|
|
|
|
|
|
|
$this.add($this_).data('order', this.options.sortOrder)
|
|
$this.add($this_).data('order', this.options.sortOrder)
|
|
|
|
|
|
|
|
// Assign the correct sortable arrow
|
|
// Assign the correct sortable arrow
|
|
|
this.getCaret()
|
|
this.getCaret()
|
|
|
|
|
|
|
|
|
|
+ this._sort()
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ _sort () {
|
|
|
|
|
+ this.trigger('sort', this.options.sortName, this.options.sortOrder)
|
|
|
|
|
+
|
|
|
if (this.options.sidePagination === 'server' && this.options.serverSort) {
|
|
if (this.options.sidePagination === 'server' && this.options.serverSort) {
|
|
|
this.options.pageNumber = 1
|
|
this.options.pageNumber = 1
|
|
|
this.initServer(this.options.silentSort)
|
|
this.initServer(this.options.silentSort)
|