|
|
@@ -530,7 +530,18 @@ class BootstrapTable {
|
|
|
${o.showButtonText ? o.formatColumns() : ''}
|
|
|
${this.constants.html.dropdownCaret}
|
|
|
</button>
|
|
|
- ${this.constants.html.toobarDropdow[0]}`)
|
|
|
+ ${this.constants.html.toolbarDropdown[0]}`)
|
|
|
+
|
|
|
+ if (o.showColumnsToggleAll) {
|
|
|
+ const allFieldsVisible = this.getVisibleColumns().length === this.columns.length
|
|
|
+ html.push(
|
|
|
+ Utils.sprintf(this.constants.html.toolbarDropdownItem,
|
|
|
+ Utils.sprintf('<input type="checkbox" class="toggle-all" %s> <span>%s</span>', allFieldsVisible ? 'checked="checked"' : '', o.formatColumnsToggleAll())
|
|
|
+ )
|
|
|
+ )
|
|
|
+
|
|
|
+ html.push(this.constants.html.toolbarDropdownSeperator)
|
|
|
+ }
|
|
|
|
|
|
this.columns.forEach((column, i) => {
|
|
|
if (column.radio || column.checkbox) {
|
|
|
@@ -544,13 +555,13 @@ class BootstrapTable {
|
|
|
const checked = column.visible ? ' checked="checked"' : ''
|
|
|
|
|
|
if (column.switchable) {
|
|
|
- html.push(Utils.sprintf(this.constants.html.toobarDropdowItem,
|
|
|
+ html.push(Utils.sprintf(this.constants.html.toolbarDropdownItem,
|
|
|
Utils.sprintf('<input type="checkbox" data-field="%s" value="%s"%s> <span>%s</span>',
|
|
|
column.field, i, checked, column.title)))
|
|
|
switchableCount++
|
|
|
}
|
|
|
})
|
|
|
- html.push(this.constants.html.toobarDropdow[1], '</div>')
|
|
|
+ html.push(this.constants.html.toolbarDropdown[1], '</div>')
|
|
|
}
|
|
|
|
|
|
html.push('</div>')
|
|
|
@@ -584,6 +595,8 @@ class BootstrapTable {
|
|
|
|
|
|
if (o.showColumns) {
|
|
|
$keepOpen = this.$toolbar.find('.keep-open')
|
|
|
+ const $checkboxes = $keepOpen.find('input:not(".toggle-all")')
|
|
|
+ const $toggleAll = $keepOpen.find('input.toggle-all')
|
|
|
|
|
|
if (switchableCount <= o.minimumCountColumns) {
|
|
|
$keepOpen.find('input').prop('disabled', true)
|
|
|
@@ -592,11 +605,17 @@ class BootstrapTable {
|
|
|
$keepOpen.find('li, label').off('click').on('click', e => {
|
|
|
e.stopImmediatePropagation()
|
|
|
})
|
|
|
- $keepOpen.find('input').off('click').on('click', ({currentTarget}) => {
|
|
|
+
|
|
|
+ $checkboxes.off('click').on('click', ({currentTarget}) => {
|
|
|
const $this = $(currentTarget)
|
|
|
|
|
|
this._toggleColumn($this.val(), $this.prop('checked'), false)
|
|
|
this.trigger('column-switch', $this.data('field'), $this.prop('checked'))
|
|
|
+ $toggleAll.prop('checked', $checkboxes.filter(':checked').length === this.columns.length)
|
|
|
+ })
|
|
|
+
|
|
|
+ $toggleAll.off('click').on('click', ({currentTarget}) => {
|
|
|
+ this._toggleAllColumns($(currentTarget).prop('checked'))
|
|
|
})
|
|
|
}
|
|
|
|
|
|
@@ -2272,8 +2291,11 @@ class BootstrapTable {
|
|
|
}
|
|
|
|
|
|
_toggleAllColumns (visible) {
|
|
|
- for (const column of this.columns) {
|
|
|
+ for (const column of this.columns.slice().reverse()) {
|
|
|
if (column.switchable) {
|
|
|
+ if (!visible && this.options.showColumns && this.getVisibleColumns().length === this.options.minimumCountColumns) {
|
|
|
+ continue
|
|
|
+ }
|
|
|
column.visible = visible
|
|
|
}
|
|
|
}
|
|
|
@@ -2283,7 +2305,17 @@ class BootstrapTable {
|
|
|
this.initPagination()
|
|
|
this.initBody()
|
|
|
if (this.options.showColumns) {
|
|
|
- const $items = this.$toolbar.find('.keep-open input').prop('disabled', false)
|
|
|
+ const $items = this.$toolbar.find('.keep-open input:not(".toggle-all")').prop('disabled', false)
|
|
|
+
|
|
|
+ if (visible) {
|
|
|
+ $items.prop('checked', visible)
|
|
|
+ } else {
|
|
|
+ $items.get().reverse().forEach((item) => {
|
|
|
+ if ($items.filter(':checked').length > this.options.minimumCountColumns) {
|
|
|
+ $(item).prop('checked', visible)
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
|
|
|
if ($items.filter(':checked').length <= this.options.minimumCountColumns) {
|
|
|
$items.filter(':checked').prop('disabled', true)
|