Browse Source

feat(js): add `theadClasses` option to supoort bootstrap v4

zhixin 7 years ago
parent
commit
7e0ccb937a

+ 7 - 0
docs/_i18n/en/documentation/table-options.md

@@ -35,6 +35,13 @@ The table options are defined in `jQuery.fn.bootstrapTable.defaults`.
         <td>The class name of table. By default, the table is bordered, you can add 'table-no-bordered' to remove table-bordered style.</td>
         <td>The class name of table. By default, the table is bordered, you can add 'table-no-bordered' to remove table-bordered style.</td>
     </tr>
     </tr>
     <tr>
     <tr>
+        <td>theadClasses</td>
+        <td>data-thead-classes</td>
+        <td>String</td>
+        <td>''</td>
+        <td>The class name of table thead. Bootstrap V4, use the modifier classes `.thead-light` or `.thead-dark` to make `<thead>`s appear light or dark gray.</td>
+    </tr>
+    <tr>
         <td>sortClass</td>
         <td>sortClass</td>
         <td>data-sort-class</td>
         <td>data-sort-class</td>
         <td>String</td>
         <td>String</td>

+ 7 - 0
docs/_i18n/es/documentation/table-options.md

@@ -35,6 +35,13 @@ Las opciones de la tabla están definidas en `jQuery.fn.bootstrapTable.defaults`
         <td>El nombre de la clase de la tabla.</td>
         <td>El nombre de la clase de la tabla.</td>
     </tr>
     </tr>
     <tr>
     <tr>
+        <td>theadClasses</td>
+        <td>data-thead-classes</td>
+        <td>String</td>
+        <td>''</td>
+        <td>El nombre de clase de la tabla thead. Bootstrap V4, use las clases modificadoras `.thead-light` o `.thead-dark` para hacer que `<thead>`s aparezca en gris claro u oscuro.</td>
+    </tr>
+    <tr>
         <td>sortClass</td>
         <td>sortClass</td>
         <td>data-sort-class</td>
         <td>data-sort-class</td>
         <td>String</td>
         <td>String</td>

+ 7 - 0
docs/_i18n/zh-cn/documentation/table-options.md

@@ -35,6 +35,13 @@
         <td>表格的类名称。默认情况下,表格是有边框的,你可以添加 'table-no-bordered' 来删除表格的边框样式。</td>
         <td>表格的类名称。默认情况下,表格是有边框的,你可以添加 'table-no-bordered' 来删除表格的边框样式。</td>
     </tr>
     </tr>
     <tr>
     <tr>
+        <td>theadClasses</td>
+        <td>data-thead-classes</td>
+        <td>String</td>
+        <td>''</td>
+        <td>表格 thead 的类名称。Bootstrap V4,使用 `.thead-light` 或者 `.thead-dark` 可以设置 `<thead>` 的样式。</td>
+    </tr>
+    <tr>
         <td>sortClass</td>
         <td>sortClass</td>
         <td>data-sort-class</td>
         <td>data-sort-class</td>
         <td>String</td>
         <td>String</td>

+ 4 - 0
src/bootstrap-table.css

@@ -264,6 +264,10 @@
     border-bottom: 1px solid #ddd;
     border-bottom: 1px solid #ddd;
 }
 }
 
 
+.bootstrap-table .table > thead.thead-dark > tr > th {
+    border-bottom: 1px solid #212529;
+}
+
 /* support bootstrap 3 */
 /* support bootstrap 3 */
 .bootstrap-table .table thead > tr > th {
 .bootstrap-table .table thead > tr > th {
     padding: 0;
     padding: 0;

+ 3 - 2
src/bootstrap-table.js

@@ -265,13 +265,14 @@
 
 
   const DEFAULTS = {
   const DEFAULTS = {
     classes: 'table table-hover',
     classes: 'table table-hover',
+    theadClasses: '',
+    sortClass: undefined,
     locale: undefined,
     locale: undefined,
     height: undefined,
     height: undefined,
     undefinedText: '-',
     undefinedText: '-',
     sortName: undefined,
     sortName: undefined,
     sortOrder: 'asc',
     sortOrder: 'asc',
     sortStable: false,
     sortStable: false,
-    sortClass: undefined,
     rememberOrder: false,
     rememberOrder: false,
     striped: false,
     striped: false,
     columns: [
     columns: [
@@ -651,7 +652,7 @@
 
 
       this.$header = this.$el.find('>thead')
       this.$header = this.$el.find('>thead')
       if (!this.$header.length) {
       if (!this.$header.length) {
-        this.$header = $('<thead></thead>').appendTo(this.$el)
+        this.$header = $(`<thead class="${this.options.theadClasses}"></thead>`).appendTo(this.$el)
       }
       }
       this.$header.find('tr').each((i, el) => {
       this.$header.find('tr').each((i, el) => {
         const column = []
         const column = []