Browse Source

Merge pull request #6576 from wenzhixin/feature/5757

Feature/5757
文翼 3 years ago
parent
commit
ff06f54e48
3 changed files with 18 additions and 2 deletions
  1. 15 0
      site/docs/api/table-options.md
  2. 2 2
      src/bootstrap-table.js
  3. 1 0
      src/constants/index.js

+ 15 - 0
site/docs/api/table-options.md

@@ -509,11 +509,26 @@ The table options are defined in `jQuery.fn.bootstrapTable.defaults`.
 - **Detail:**
 
   Escapes a string for insertion into HTML, replacing &, <, >, ", `, and ' characters.
+  To disable it for the column titles check the `escapeTitle` option.
 
 - **Default:** `false`
 
 - **Example:** [Table Escape](https://examples.bootstrap-table.com/#options/table-escape.html)
 
+## escapeTitle
+
+- **Attribute:** `data-escape-title`
+
+- **Type:** `Boolean`
+
+- **Detail:**
+
+  Toggles if the `escape` option should be applied to the column titles.
+
+- **Default:** `true`
+
+- **Example:** [Table Escape title](https://examples.bootstrap-table.com/#options/table-escape-title.html)
+
 ## filterOptions
 
 - **Attribute:** `data-filter-options`

+ 2 - 2
src/bootstrap-table.js

@@ -355,7 +355,7 @@ class BootstrapTable {
         html.push(Utils.sprintf('<div class="th-inner %s">',
           this.options.sortable && column.sortable ? `sortable${columnHalign === 'center' ? ' sortable-center' : ''} both` : ''))
 
-        let text = this.options.escape ? Utils.escapeHTML(column.title) : column.title
+        let text = this.options.escape && this.options.escapeTitle ? Utils.escapeHTML(column.title) : column.title
 
         const title = text
 
@@ -3347,7 +3347,7 @@ class BootstrapTable {
     }
 
     this.columns[this.fieldsColumnsIndex[params.field]].title =
-      this.options.escape ? Utils.escapeHTML(params.title) : params.title
+      this.options.escape && this.options.escapeTitle ? Utils.escapeHTML(params.title) : params.title
 
     if (this.columns[this.fieldsColumnsIndex[params.field]].visible) {
       this.$header.find('th[data-field]').each((i, el) => {

+ 1 - 0
src/constants/index.js

@@ -210,6 +210,7 @@ const DEFAULTS = {
   showFullscreen: false,
   smartDisplay: true,
   escape: false,
+  escapeTitle: true,
   filterOptions: {
     filterAlgorithm: 'and'
   },