diff --git a/index.d.ts b/index.d.ts index 25ed80a7ab..feb021ebe3 100644 --- a/index.d.ts +++ b/index.d.ts @@ -325,6 +325,7 @@ export interface BootstrapTableOptions { ) => boolean | void; buttonsClass?: string; pageList?: number[]; + fixedScroll?: boolean; } declare global { diff --git a/site/docs/api/table-options.md b/site/docs/api/table-options.md index 0f2edd5272..b245220b57 100644 --- a/site/docs/api/table-options.md +++ b/site/docs/api/table-options.md @@ -543,6 +543,20 @@ The table options are defined in `jQuery.fn.bootstrapTable.defaults`. - **Example:** [Filter Options](https://examples.bootstrap-table.com/#options/filter-options.html) +## fixedScroll + +- **Attribute:** `data-fixed-scroll` + +- **Type:** `Boolean` + +- **Detail:** + + Set `true` to enable the fixed scrollbar position of the table when loading data. + +- **Default:** `false` + +- **Example:** [Fixed Scroll](https://examples.bootstrap-table.com/#options/fixed-scroll.html) + ## footerField - **Attribute:** `data-footer-field` diff --git a/src/bootstrap-table.js b/src/bootstrap-table.js index 2934786ffd..5ed30e7a32 100644 --- a/src/bootstrap-table.js +++ b/src/bootstrap-table.js @@ -2516,7 +2516,7 @@ class BootstrapTable { this.footerData = data[this.options.footerField] ? [data[this.options.footerField]] : undefined } - fixedScroll = data.fixedScroll + fixedScroll = this.options.fixedScroll || data.fixedScroll data = Array.isArray(data) ? data : data[this.options.dataField] this.initData(data) diff --git a/src/constants/index.js b/src/constants/index.js index bc1ea17581..0f651116ce 100644 --- a/src/constants/index.js +++ b/src/constants/index.js @@ -247,6 +247,7 @@ const DEFAULTS = { iconsPrefix: undefined, // init in initConstants icons: {}, // init in initConstants iconSize: undefined, + fixedScroll: false, loadingFontSize: 'auto', loadingTemplate (loadingMessage) { return `