Browse Source

Updated the parameter of and supported css/classes.

zhixin 6 years ago
parent
commit
5181c30d26
3 changed files with 15 additions and 8 deletions
  1. 1 0
      CHANGELOG.md
  2. 7 5
      site/docs/api/table-options.md
  3. 7 3
      src/bootstrap-table.js

+ 1 - 0
CHANGELOG.md

@@ -9,6 +9,7 @@ ChangeLog
 - **Update(js):** Fixed show footer cannot work bug.
 - **Update(js):** Fixed IE11 transform bug.
 - **Update(js):** Removed beginning and end whitespace from td.
+- **Update(js):** Updated the parameter of `footerStyle` and supported css/classes.
 - **Update(export extension):** Fixed export selected bug.
 
 ### 1.13.4

+ 7 - 5
site/docs/api/table-options.md

@@ -857,23 +857,25 @@ The table options are defined in `jQuery.fn.bootstrapTable.defaults`.
 
 - **Detail:**
 
-  The footer style formatter function, takes two parameters:
+  The footer style formatter function, takes one parameter:
 
-  * `row`: the row record data.
-  * `index`: the row index.
+  * `column`: the column object.
 
   Support classes or css. Example usage:
 
   {% highlight javascript %}
-  function footerStyle(value, row, index) {
+  function footerStyle(column) {
     return {
-      css: { "font-weight": "bold" }
+      css: { 'font-weight': 'normal' },
+      classes: 'my-class'
     }
   }
   {% endhighlight %}
 
 - **Default:** `{}`
 
+- **Example:** [Footer Style](https://examples.bootstrap-table.com/#options/footer-style.html)
+
 ## showColumns
 
 - **Attribute:** `data-show-columns`

+ 7 - 3
src/bootstrap-table.js

@@ -2291,7 +2291,7 @@
         let valign = ''
         const csses = []
         let style = {}
-        const class_ = Utils.sprintf(' class="%s"', column['class'])
+        let class_ = Utils.sprintf(' class="%s"', column['class'])
 
         if (!column.visible) {
           return
@@ -2304,13 +2304,17 @@
         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)
+        style = Utils.calculateObjectValue(null, this.options.footerStyle, [column])
 
         if (style && style.css) {
-          for (const [key, value] of Object.keys(style.css)) {
+          for (const [key, value] of Object.entries(style.css)) {
             csses.push(`${key}: ${value}`)
           }
         }
+        if (style && style.classes) {
+          class_ = Utils.sprintf(' class="%s"', column['class'] ?
+            [column['class'], style.classes].join(' ') : style.classes)
+        }
 
         html.push('<th', class_, Utils.sprintf(' style="%s"', falign + valign + csses.concat().join('; ')), '>')
         html.push('<div class="th-inner">')