Skip to content

Commit

Permalink
Fix wenzhixin#2742: add showSelectTitle column option
Browse files Browse the repository at this point in the history
  • Loading branch information
wenzhixin committed Dec 27, 2017
1 parent fcfbe0c commit 9faa566
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 3 deletions.
11 changes: 10 additions & 1 deletion docs/_i18n/en/documentation/column-options.md
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,16 @@ function cellStyle(value, row, index, field) {
<td>Boolean</td>
<td>false</td>
<td>
Escapes a string for insertion into HTML, replacing &, <, >, ", `, and ' characters.
Escapes a string for insertion into HTML, replacing &, <, >, ", \`, and ' characters.
</td>
</tr>
<tr>
<td>showSelectTitle</td>
<td>data-show-select-title</td>
<td>Boolean</td>
<td>false</td>
<td>
True to show the title of column with `radio` or `singleSelect` `checkbox` option.
</td>
</tr>
</tbody>
Expand Down
18 changes: 18 additions & 0 deletions docs/_i18n/es/documentation/column-options.md
Original file line number Diff line number Diff line change
Expand Up @@ -242,5 +242,23 @@ Las propiedades de la columna están definidas en `jQuery.fn.bootstrapTable.colu
True to search use formated data.
</td>
</tr>
<tr>
<td>escape</td>
<td>data-escape</td>
<td>Boolean</td>
<td>false</td>
<td>
Escapes a string for insertion into HTML, replacing &, <, >, ", \`, and ' characters.
</td>
</tr>
<tr>
<td>showSelectTitle</td>
<td>data-show-select-title</td>
<td>Boolean</td>
<td>false</td>
<td>
Show the title of column with radio or singleSelect checkbox.
</td>
</tr>
</tbody>
</table>
18 changes: 18 additions & 0 deletions docs/_i18n/zh-cn/documentation/column-options.md
Original file line number Diff line number Diff line change
Expand Up @@ -246,5 +246,23 @@ The column options is defined in `jQuery.fn.bootstrapTable.columnDefaults`.
True to search use formated data.
</td>
</tr>
<tr>
<td>escape</td>
<td>data-escape</td>
<td>Boolean</td>
<td>false</td>
<td>
Escapes a string for insertion into HTML, replacing &, <, >, ", \`, and ' characters.
</td>
</tr>
<tr>
<td>showSelectTitle</td>
<td>data-show-select-title</td>
<td>Boolean</td>
<td>false</td>
<td>
True to show the title of column with 'radio' or 'singleSelect' 'checkbox' option.
</td>
</tr>
</tbody>
</table>
11 changes: 9 additions & 2 deletions src/bootstrap-table.js
Original file line number Diff line number Diff line change
Expand Up @@ -576,7 +576,8 @@
searchable: true,
searchFormatter: true,
cardVisible: true,
escape : false
escape: false,
showSelectTitle: false
};

BootstrapTable.EVENTS = {
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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 = '<input name="btSelectAll" type="checkbox" />';
}
Expand All @@ -891,6 +895,9 @@
that.header.stateField = column.field;
that.options.singleSelect = true;
}
if (!text && column.showSelectTitle) {
text += title;
}

html.push(text);
html.push('</div>');
Expand Down

0 comments on commit 9faa566

Please sign in to comment.