Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,18 @@
ChangeLog
---------

### Next

#### Breaking changes in 1.25.x

- Remove `toolbarAlign` in favour of flexbox. To migrate, simply override CSS. IE if you previously specified right alignment, using Bootstrap:
```
@media(min-width: "992px") {
.bs-bars {
margin-right: none; /** Instead of margin-right: auto */
}
}
```
### 1.24.1

#### Core
Expand Down
2 changes: 1 addition & 1 deletion dist/bootstrap-table.js
Original file line number Diff line number Diff line change
Expand Up @@ -8558,7 +8558,7 @@
}
this.$toolbar.html('');
if (typeof opts.toolbar === 'string' || _typeof(opts.toolbar) === 'object') {
$(Utils.sprintf('<div class="bs-bars %s-%s"></div>', this.constants.classes.pull, opts.toolbarAlign)).appendTo(this.$toolbar).append($(opts.toolbar));
$('<div class="bs-bars"></div>').appendTo(this.$toolbar).append($(opts.toolbar));
}

// showColumns, showToggle, showRefresh
Expand Down
1 change: 0 additions & 1 deletion index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,6 @@ export interface BootstrapTableOptions {
searchOnEnterKey?: boolean;
searchText?: string;
responseHandler?: (res: any) => any;
toolbarAlign?: string;
paginationParts?: string[];
cardView?: boolean;
showSearchButton?: boolean;
Expand Down
14 changes: 0 additions & 14 deletions site/docs/api/table-options.md
Original file line number Diff line number Diff line change
Expand Up @@ -1825,20 +1825,6 @@ The table options are defined in `jQuery.fn.bootstrapTable.defaults`.

- **Example:** [Custom Toolbar](https://examples.bootstrap-table.com/#options/custom-toolbar.html)

## toolbarAlign

- **Attribute:** `data-toolbar-align`

- **Type:** `String`

- **Detail:**

Indicate how to align the custom toolbar. `'left'`, `'right'` can be used.

- **Default:** `'left'`

- **Example:** [Toolbar Align](https://examples.bootstrap-table.com/#options/toolbar-align.html)

## totalField

- **Attribute:** `data-total-field`
Expand Down
91 changes: 47 additions & 44 deletions src/bootstrap-table.js
Original file line number Diff line number Diff line change
Expand Up @@ -608,6 +608,51 @@ class BootstrapTable {
this.initBody()
}

renderButton (buttonName, buttonConfig) {
let buttonHtml

if (buttonConfig.hasOwnProperty('html')) {
if (typeof buttonConfig.html === 'function') {
buttonHtml = buttonConfig.html()
} else if (typeof buttonConfig.html === 'string') {
buttonHtml = buttonConfig.html
}
} else {
let buttonClass = this.constants.buttonsClass

if (buttonConfig.hasOwnProperty('attributes') && buttonConfig.attributes.class) {
buttonClass += ` ${buttonConfig.attributes.class}`
}
buttonHtml = `<button class="${buttonClass}" type="button" name="${buttonName}"`

if (buttonConfig.hasOwnProperty('attributes')) {
for (const [attributeName, value] of Object.entries(buttonConfig.attributes)) {
if (attributeName === 'class') {
continue
}

const attribute = attributeName === 'title' ?
this.options.buttonsAttributeTitle : attributeName

buttonHtml += ` ${attribute}="${value}"`
}
}

buttonHtml += '>'

if (opts.showButtonIcons && buttonConfig.hasOwnProperty('icon')) {
buttonHtml += `${Utils.sprintf(this.constants.html.icon, opts.iconsPrefix, buttonConfig.icon)} `
}

if (opts.showButtonText && buttonConfig.hasOwnProperty('text')) {
buttonHtml += buttonConfig.text
}

buttonHtml += '</button>'
}
return buttonHtml
}

initToolbar () {
const opts = this.options
let html = []
Expand All @@ -621,7 +666,7 @@ class BootstrapTable {
this.$toolbar.html('')

if (typeof opts.toolbar === 'string' || typeof opts.toolbar === 'object') {
$(Utils.sprintf('<div class="bs-bars %s-%s"></div>', this.constants.classes.pull, opts.toolbarAlign))
$('<div class="bs-bars"></div>')
.appendTo(this.$toolbar)
.append($(opts.toolbar))
}
Expand Down Expand Up @@ -751,49 +796,7 @@ class BootstrapTable {
const buttonsHtml = {}

for (const [buttonName, buttonConfig] of Object.entries(this.buttons)) {
let buttonHtml

if (buttonConfig.hasOwnProperty('html')) {
if (typeof buttonConfig.html === 'function') {
buttonHtml = buttonConfig.html()
} else if (typeof buttonConfig.html === 'string') {
buttonHtml = buttonConfig.html
}
} else {
let buttonClass = this.constants.buttonsClass

if (buttonConfig.hasOwnProperty('attributes') && buttonConfig.attributes.class) {
buttonClass += ` ${buttonConfig.attributes.class}`
}
buttonHtml = `<button class="${buttonClass}" type="button" name="${buttonName}"`

if (buttonConfig.hasOwnProperty('attributes')) {
for (const [attributeName, value] of Object.entries(buttonConfig.attributes)) {
if (attributeName === 'class') {
continue
}

const attribute = attributeName === 'title' ?
this.options.buttonsAttributeTitle : attributeName

buttonHtml += ` ${attribute}="${value}"`
}
}

buttonHtml += '>'

if (opts.showButtonIcons && buttonConfig.hasOwnProperty('icon')) {
buttonHtml += `${Utils.sprintf(this.constants.html.icon, opts.iconsPrefix, buttonConfig.icon)} `
}

if (opts.showButtonText && buttonConfig.hasOwnProperty('text')) {
buttonHtml += buttonConfig.text
}

buttonHtml += '</button>'
}

buttonsHtml[buttonName] = buttonHtml
buttonsHtml[buttonName] = renderButton(buttonName, buttonConfig)
const optionName = `show${buttonName.charAt(0).toUpperCase()}${buttonName.substring(1)}`
const showOption = opts[optionName]

Expand Down
1 change: 0 additions & 1 deletion src/constants/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,6 @@ const DEFAULTS = {
strictSearch: false,
theadClasses: '',
toolbar: undefined,
toolbarAlign: 'left',
totalField: 'total',
totalNotFiltered: 0,
totalNotFilteredField: 'totalNotFiltered',
Expand Down
22 changes: 22 additions & 0 deletions src/themes/_theme.scss
Original file line number Diff line number Diff line change
@@ -1,7 +1,29 @@
@use "variables";

/**
* Same as Bootstrap 5's "Large" breakpoint.
* @todo Refactor if other frameworks have different breakpoints
* @todo Is it safe to use bootstrap 5 equivalents?
*/
@media(min-width: "992px") {
.fixed-table-toolbar {
align-items: flex-end;
}
.bs-bars {
margin-right: auto;
}
}

@media(max-width: "991px") {
.fixed-table-toolbar {
flex-direction: column;
}
}

.bootstrap-table {
.fixed-table-toolbar {
display: flex;

&::after {
content: "";
display: block;
Expand Down