Skip to content

Commit 8edc824

Browse files
author
Egor Trutnev
committed
fix
1 parent 35b42a0 commit 8edc824

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

src/bootstrap-table.js

+9-4
Original file line numberDiff line numberDiff line change
@@ -483,10 +483,11 @@ class BootstrapTable {
483483
}
484484

485485
initSort () {
486-
let name = this.options.sortName
486+
const name = this.options.sortName
487487
const order = this.options.sortOrder === 'desc' ? -1 : 1
488488
const index = this.header.fields.indexOf(this.options.sortName)
489489
let timeoutId = 0
490+
490491
if (index !== -1) {
491492
if (this.options.sortStable) {
492493
this.data.forEach((row, i) => {
@@ -503,18 +504,22 @@ class BootstrapTable {
503504
])
504505
} else if (this.options.groupBy === true && this.options.groupByField !== '') {
505506
const groupedData = {}
507+
506508
this.data.forEach(item => {
507-
const groupKey = Utils.getItemField(item, this.options.groupByField, this.options.escape);
509+
const groupKey = Utils.getItemField(item, this.options.groupByField, this.options.escape)
510+
508511
if (!groupedData[groupKey]) {
509512
groupedData[groupKey] = []
510513
}
511514
groupedData[groupKey].push(item)
512-
});
515+
})
513516
const sortedGroups = Object.keys(groupedData).map(groupKey => {
514517
const group = groupedData[groupKey]
518+
515519
Utils.sort(name, order, index, group, this.header, this.options)
516520
return group
517-
});
521+
})
522+
518523
this.data = [].concat(...sortedGroups)
519524
} else {
520525
Utils.sort(name, order, index, this.data, this.header, this.options)

src/utils/index.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -520,9 +520,9 @@ export default {
520520
name = header.sortNames[index]
521521
}
522522

523-
let aa = getItemField(a, name, options.escape)
524-
let bb = getItemField(b, name, options.escape)
525-
const value = calculateObjectValue(header, header.sorters[index], [aa, bb, a, b])
523+
let aa = this.getItemField(a, name, options.escape)
524+
let bb = this.getItemField(b, name, options.escape)
525+
const value = this.calculateObjectValue(header, header.sorters[index], [aa, bb, a, b])
526526

527527
if (value !== undefined) {
528528
if (options.sortStable && value === 0) {

0 commit comments

Comments
 (0)