10000 fix(js): fix #2485, selections bugs · pythonAI/bootstrap-table@37c3e03 · GitHub
[go: up one dir, main page]

Skip to content

Commit 37c3e03

Browse files
committed
fix(js): fix wenzhixin#2485, selections bugs
1 parent 53b9c80 commit 37c3e03

File tree

1 file changed

+13
-17
lines changed

1 file changed

+13
-17
lines changed

src/bootstrap-table.js

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -243,9 +243,7 @@
243243

244244
const props = field.split('.')
245245
for (const p of props) {
246-
if (props.hasOwnProperty(p)) {
247-
value = value && value[props[p]]
248-
}
246+
value = value && value[p]
249247
}
250248
return escape ? this.escapeHTML(value) : value
251249
},
@@ -1776,6 +1774,9 @@
17761774
type = column.radio ? 'radio' : type
17771775

17781776
const c = column['class'] || ''
1777+
const isChecked = value === true || (value_ || value && value.checked)
1778+
const isDisabled = !column.checkboxEnabled || (value && value.disabled)
1779+
17791780
text = [
17801781
this.options.cardView
17811782
? `<div class="card-view ${c}">`
@@ -1784,9 +1785,9 @@
17841785
data-index="${i}"
17851786
name="${this.options.selectItemName}"
17861787
type="${type}"
1787-
value="${item[this.options.idField]}"
1788-
${value === true || (value_ || (value && value.checked)) ? 'checked="checked"' : ''}
1789-
${!column.checkboxEnabled || (value && value.disabled) ? 'disabled="disabled"' : ''} />`,
1788+
${Utils.sprintf('value="%s"', item[this.options.idField])}
1789+
${Utils.sprintf('checked="%s"', isChecked ? 'checked' : undefined)}
1790+
${Utils.sprintf('disabled="%s"', isDisabled ? 'disabled' : undefined)} />`,
17901791
this.header.formatters[j] && typeof value === 'string' ? value : '',
17911792
this.options.cardView ? '</div>' : '</td>'
17921793
].join('')
@@ -1878,7 +1879,7 @@
18781879
e.type === 'click' &&
18791880
this.options.clickToSelect &&
18801881
column.clickToSelect &&
1881-
this.options.ignoreClickToSelectOn(e.target)
1882+
!this.options.ignoreClickToSelectOn(e.target)
18821883
) {
18831884
const $selectItem = $tr.find(Utils.sprintf('[name="%s"]', this.options.selectItemName))
18841885
if ($selectItem.length) {
@@ -1923,20 +1924,14 @@
19231924
const row = this.data[$this.data('index')]
19241925

19251926
if ($(e.currentTarget).is(':radio') || this.options.singleSelect) {
1926-
for (let row of this.options.data) {
1927-
row[this.header.stateField] = false
1927+
for (let r of this.options.data) {
1928+
r[this.header.stateField] = false
19281929
}
1930+
this.$selectItem.filter(':checked').not($this).prop('checked', false)
19291931
}
19301932

19311933
row[this.header.stateField] = checked
19321934

1933-
if (this.options.singleSelect) {
1934-
this.$selectItem.not(this).each((i, el) => {
1935-
this.data[$(el).data('index')][this.header.stateField] = false
1936-
})
1937-
this.$selectItem.filter(':checked').not(this).prop('checked', false)
1938-
}
1939-
19401935
this.updateSelected()
19411936
this.trigger(checked ? 'check' : 'uncheck', row, $this)
19421937
})
@@ -2765,7 +2760,8 @@
27652760
}
27662761

27672762
getSelections () {
2768-
return (this.options.data, row => // fix #2424: from html with checkbox
2763+
// fix #2424: from html with checkbox
2764+
return this.options.data.filter(row =>
27692765
row[this.header.stateField] === true)
27702766
}
27712767

0 commit comments

Comments
 (0)
0