浏览代码

feat (column options): column-specific footerStyle added

Arthur 2 年之前
父节点
当前提交
795e907bcd
共有 4 个文件被更改,包括 30 次插入1 次删除
  1. 1 0
      index.d.ts
  2. 27 0
      site/docs/api/column-options.md
  3. 1 1
      src/bootstrap-table.js
  4. 1 0
      src/constants/index.js

+ 1 - 0
index.d.ts

@@ -75,6 +75,7 @@ export interface BootstrapTableColumn {
   cellStyle?: any;
   searchable?: boolean;
   footerFormatter?: any;
+  footerStyle?: any;
   formatter?: any;
   checkboxEnabled?: boolean;
   field?: any;

+ 27 - 0
site/docs/api/column-options.md

@@ -238,6 +238,33 @@ The column options is defined in `jQuery.fn.bootstrapTable.columnDefaults`.
 
 - **Example:** [Footer Formatter](https://examples.bootstrap-table.com/#column-options/footer-formatter.html)
 
+## footerStyle
+
+- **Attribute:** `data-footer-style`
+
+- **Type:** `Function`
+
+- **Detail:**
+
+  The footer style formatter function, takes one parameter:
+
+  * `column`: the column object.
+
+  Support `classes` or `css`. Example usage:
+
+  {% highlight javascript %}
+  function footerStyle(column) {
+    return {
+      css: { 'font-weight': 'normal' },
+      classes: 'my-class'
+    }
+  }
+  {% endhighlight %}
+
+- **Default:** `{}`
+
+- **Example:** [Footer Style](https://examples.bootstrap-table.com/#options/footer-style.html)
+
 ## formatter
 
 - **Attribute:** `data-formatter`

+ 1 - 1
src/bootstrap-table.js

@@ -2292,7 +2292,7 @@ class BootstrapTable {
       falign = Utils.sprintf('text-align: %s; ', column.falign ? column.falign : column.align)
       valign = Utils.sprintf('vertical-align: %s; ', column.valign)
 
-      style = Utils.calculateObjectValue(null, this.options.footerStyle, [column])
+      style = Utils.calculateObjectValue(null, column.footerStyle || this.options.footerStyle, [column])
 
       if (style && style.css) {
         for (const [key, value] of Object.entries(style.css)) {

+ 1 - 0
src/constants/index.js

@@ -447,6 +447,7 @@ const COLUMN_DEFAULTS = {
   searchable: true,
   formatter: undefined,
   footerFormatter: undefined,
+  footerStyle: undefined,
   detailFormatter: undefined,
   searchFormatter: true,
   searchHighlightFormatter: false,