浏览代码

Fix #2742: add showSelectTitle column option

zhixin 8 年之前
父节点
当前提交
9faa566947

+ 10 - 1
docs/_i18n/en/documentation/column-options.md

@@ -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>

+ 18 - 0
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.
         </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 - 0
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.
         </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>

+ 9 - 2
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 = '<input name="btSelectAll" type="checkbox" />';
                     }
@@ -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>');