From 9faa566947611ab2ac5bdbc10845a20c921bb8a9 Mon Sep 17 00:00:00 2001 From: zhixin Date: Wed, 27 Dec 2017 23:10:55 +0800 Subject: [PATCH] Fix #2742: add showSelectTitle column option --- docs/_i18n/en/documentation/column-options.md | 11 ++++++++++- docs/_i18n/es/documentation/column-options.md | 18 ++++++++++++++++++ .../zh-cn/documentation/column-options.md | 18 ++++++++++++++++++ src/bootstrap-table.js | 11 +++++++++-- 4 files changed, 55 insertions(+), 3 deletions(-) diff --git a/docs/_i18n/en/documentation/column-options.md b/docs/_i18n/en/documentation/column-options.md index a44c4f95b2..669de032b4 100644 --- a/docs/_i18n/en/documentation/column-options.md +++ b/docs/_i18n/en/documentation/column-options.md @@ -273,7 +273,16 @@ function cellStyle(value, row, index, field) { Boolean false - Escapes a string for insertion into HTML, replacing &, <, >, ", `, and ' characters. + Escapes a string for insertion into HTML, replacing &, <, >, ", \`, and ' characters. + + + + showSelectTitle + data-show-select-title + Boolean + false + + True to show the title of column with `radio` or `singleSelect` `checkbox` option. diff --git a/docs/_i18n/es/documentation/column-options.md b/docs/_i18n/es/documentation/column-options.md index fe75ba6792..27da0a8ab2 100644 --- a/docs/_i18n/es/documentation/column-options.md +++ b/docs/_i18n/es/documentation/column-options.md @@ -242,5 +242,23 @@ Las propiedades de la columna están definidas en `jQuery.fn.bootstrapTable.colu True to search use formated data. + + escape + data-escape + Boolean + false + + Escapes a string for insertion into HTML, replacing &, <, >, ", \`, and ' characters. + + + + showSelectTitle + data-show-select-title + Boolean + false + + Show the title of column with radio or singleSelect checkbox. + + diff --git a/docs/_i18n/zh-cn/documentation/column-options.md b/docs/_i18n/zh-cn/documentation/column-options.md index 9d065f1d21..2b58fcc54c 100644 --- a/docs/_i18n/zh-cn/documentation/column-options.md +++ b/docs/_i18n/zh-cn/documentation/column-options.md @@ -246,5 +246,23 @@ The column options is defined in `jQuery.fn.bootstrapTable.columnDefaults`. True to search use formated data. + + escape + data-escape + Boolean + false + + Escapes a string for insertion into HTML, replacing &, <, >, ", \`, and ' characters. + + + + showSelectTitle + data-show-select-title + Boolean + false + + True to show the title of column with 'radio' or 'singleSelect' 'checkbox' option. + + diff --git a/src/bootstrap-table.js b/src/bootstrap-table.js index e3e33d3096..ad3af4d9f2 100644 --- a/src/bootstrap-table.js +++ b/src/bootstrap-table.js @@ -576,7 +576,8 @@ searchable: true, searchFormatter: true, cardVisible: true, - escape : false + escape: false, + showSelectTitle: false }; BootstrapTable.EVENTS = { @@ -840,7 +841,8 @@ align = sprintf('text-align: %s; ', column.align); style = sprintf('vertical-align: %s; ', column.valign); style += sprintf('width: %s; ', (column.checkbox || column.radio) && !width ? - '36px' : (width ? width + unitWidth : undefined)); + (!column.showSelectTitle ? '36px' : undefined) : + (width ? width + unitWidth : undefined)); if (typeof column.fieldIndex !== 'undefined') { that.header.fields[column.fieldIndex] = column.field; @@ -880,7 +882,9 @@ text = that.options.escape ? escapeHTML(column.title) : column.title; + var title = text; if (column.checkbox) { + text = ''; if (!that.options.singleSelect && that.options.checkboxHeader) { text = ''; } @@ -891,6 +895,9 @@ that.header.stateField = column.field; that.options.singleSelect = true; } + if (!text && column.showSelectTitle) { + text += title; + } html.push(text); html.push('');