Skip to content

Commit 0d754d4

Browse files
committed
Fix filter-control select option loss and sticky-header undefined crash
1 parent 7caa038 commit 0d754d4

2 files changed

Lines changed: 10 additions & 14 deletions

File tree

src/extensions/filter-control/utils.js

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -474,18 +474,7 @@ export function createControls (that, header) {
474474
const $selectControl = $(currentTarget)
475475
const value = $selectControl.val()
476476

477-
if (Array.isArray(value)) {
478-
for (let i = 0; i < value.length; i++) {
479-
if (value[i] && value[i].length > 0 && value[i].trim()) {
480-
$selectControl.find(`option[value="${value[i]}"]`).attr('selected', true)
481-
}
482-
}
483-
} else if (value && value.length > 0 && value.trim()) {
484-
$selectControl.find('option[selected]').removeAttr('selected')
485-
$selectControl.find(`option[value="${value}"]`).attr('selected', true)
486-
} else {
487-
$selectControl.find('option[selected]').removeAttr('selected')
488-
}
477+
$selectControl.val(value === null ? $selectControl.prop('multiple') ? [] : null : value)
489478

490479
clearTimeout(currentTarget.timeoutId || 0)
491480
currentTarget.timeoutId = setTimeout(() => {

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

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,14 @@ $.BootstrapTable = class extends $.BootstrapTable {
8989
renderStickyHeader () {
9090
const that = this
9191

92+
if (
93+
!this.$stickyContainer || !this.$stickyContainer.length ||
94+
!this.$stickyBegin || !this.$stickyBegin.length ||
95+
!this.$stickyEnd || !this.$stickyEnd.length
96+
) {
97+
return
98+
}
99+
92100
this.$stickyHeader = this.$header.clone(true, true)
93101

94102
if (this.options.filterControl) {
@@ -103,8 +111,7 @@ $.BootstrapTable = class extends $.BootstrapTable {
103111
} else if ($target.is('select')) {
104112
const $select = $coreTh.find('select')
105113

106-
$select.find('option[selected]').removeAttr('selected')
107-
$select.find(`option[value="${value}"]`).attr('selected', true)
114+
$select.val(value === null ? $select.prop('multiple') ? [] : null : value)
108115
}
109116

110117
that.triggerSearch()

0 commit comments

Comments
 (0)