ソースを参照

Merge branch 'master' of https://github.com/djhvscf/bootstrap-table

Dennis Hernández 10 年 前
コミット
f1d3110892

+ 4 - 2
CHANGELOG.md

@@ -4,9 +4,11 @@
 
 - [bug] Fix #672: Column Fixed Width in Percentage bug.
 - [enh] Added state saving for visible columns and the ability to use extension with multiple simultaneous tables.
-- [enh] Added `ajax' option to replace jquery ajax method.
+- [enh] Added `ajax` option to replace jquery ajax method.
 - [enh] Added `resetWidth` method to reset header and footer width.
-- [enh] Added keyevents extension.
+- [enh] Added keyevents, mobile extensions.
+- [enh] Added `onToggle`, `onColumnSearch` events.
+- [enh] Added `getScrollPosition` method.
 
 ### 1.7.0
 

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

@@ -180,6 +180,16 @@ The column options is defined in `jQuery.fn.bootstrapTable.columnDefaults`.
         </td>
     </tr>
     <tr>
+        <td>sortName</td>
+        <td>data-sort-name</td>
+        <td>String</td>
+        <td>undefined</td>
+        <td>Provide a customizable sort-name, not the default sort-name in the header, or the field name
+        of the column. For example, a column might display the value of fieldName of "html" such as  
+        "&lt;b&gt;&lt;span style="color:red"&gt;abc&lt;/span&gt;&lt;/b&gt;", but a fieldName to sort is "content" with the value of "abc".
+        </td>
+    </tr>    
+    <tr>
         <td>cellStyle</td>
         <td>data-cell-style</td>
         <td>Function</td>

+ 6 - 0
docs/_i18n/en/documentation/events.md

@@ -131,6 +131,12 @@
         <td>Fires when search the table.</td>
     </tr>
     <tr>
+        <td>onToggle</td>
+        <td>toggle.bs.table</td>
+        <td>cardView</td>
+        <td>Fires when toggle the view of table.</td>
+    </tr>
+    <tr>
         <td>onPreBody</td>
         <td>pre-body.bs.table</td>
         <td>data</td>

+ 35 - 0
docs/_i18n/en/extensions/mobile.md

@@ -0,0 +1,35 @@
+# Table Mobile
+
+Use Plugin: [bootstrap-table-mobile](https://github.com/wenzhixin/bootstrap-table/tree/master/src/extensions/mobile)
+
+## Usage
+
+```html
+<script src="extensions/mobile/bootstrap-table-mobile.js"></script>
+```
+
+## Options
+
+### mobileResponsive
+
+* type: Boolean
+* description: Set true to change the view between card and table view depending on width and height given.
+* default: `false`
+
+### checkOnInit
+
+* type: Boolean
+* description: Set true to check the window size on init.
+* default: `false`
+
+### minWidth
+
+* type: Integer
+* description: Set the minimum width when the table will change the view.
+* default: `562`
+
+### minHeight
+
+* type: Integer
+* description: Set the minimum height when the table will change the view.
+* default: `562`

+ 10 - 0
docs/_i18n/es/documentation/column-options.md

@@ -177,6 +177,16 @@ Las propiedades de la columna están definidas en `jQuery.fn.bootstrapTable.colu
         b: el segundo valor del campo.</td>
     </tr>
     <tr>
+        <td>sortName</td>
+        <td>data-sort-name</td>
+        <td>String</td>
+        <td>undefined</td>
+        <td>Proporcionar una especie-nombre adaptable, no la clase-nombre por defecto en la cabecera, o el nombre del campo
+         de la columna. Por ejemplo, una columna puede mostrar el valor de nombreCampo de "HTML" como
+         "&lt;b&gt;&lt;span style="color:red"&gt;abc&lt;/span&gt;&lt;/b&gt;", pero una nombreCampo para ordenar es el "contenido" con el valor de "abc".
+        </td>
+    </tr>    
+    <tr>
         <td>cellStyle</td>
         <td>data-cell-style</td>
         <td>Function</td>

+ 35 - 0
docs/_i18n/es/extensions/mobile.md

@@ -0,0 +1,35 @@
+# Table Mobile
+
+Use Plugin: [bootstrap-table-mobile](https://github.com/wenzhixin/bootstrap-table/tree/master/src/extensions/mobile)
+
+## Usage
+
+```html
+<script src="extensions/mobile/bootstrap-table-mobile.js"></script>
+```
+
+## Options
+
+### mobileResponsive
+
+* type: Boolean
+* description: Set true to change the view between card and table view depending on width and height given.
+* default: `false`
+
+### checkOnInit
+
+* type: Boolean
+* description: Set true to check the window size on init.
+* default: `false`
+
+### minWidth
+
+* type: Integer
+* description: Set the minimum width when the table will change the view.
+* default: `562`
+
+### minHeight
+
+* type: Integer
+* description: Set the minimum height when the table will change the view.
+* default: `562`

+ 10 - 0
docs/_i18n/zh-cn/documentation/column-options.md

@@ -154,6 +154,16 @@ The column options is defined in `jQuery.fn.bootstrapTable.columnDefaults`.
         </td>
     </tr>
     <tr>
+        <td>sortName</td>
+        <td>data-sort-name</td>
+        <td>String</td>
+        <td>undefined</td>
+        <td>Provide a customizable sort-name, not the default sort-name in the header, or the field name
+        of the column. For example, a column might display the value of fieldName of "html" such as  
+        "&lt;b&gt;&lt;span style="color:red"&gt;abc&lt;/span&gt;&lt;/b&gt;", but a fieldName to sort is "content" with the value of "abc".
+        </td>
+    </tr>  
+    <tr>
         <td>cellStyle</td>
         <td>data-cell-style</td>
         <td>Function</td>

+ 35 - 0
docs/_i18n/zh-cn/extensions/mobile.md

@@ -0,0 +1,35 @@
+# Table Mobile
+
+Use Plugin: [bootstrap-table-mobile](https://github.com/wenzhixin/bootstrap-table/tree/master/src/extensions/mobile)
+
+## Usage
+
+```html
+<script src="extensions/mobile/bootstrap-table-mobile.js"></script>
+```
+
+## Options
+
+### mobileResponsive
+
+* type: Boolean
+* description: Set true to change the view between card and table view depending on width and height given.
+* default: `false`
+
+### checkOnInit
+
+* type: Boolean
+* description: Set true to check the window size on init.
+* default: `false`
+
+### minWidth
+
+* type: Integer
+* description: Set the minimum width when the table will change the view.
+* default: `562`
+
+### minHeight
+
+* type: Integer
+* description: Set the minimum height when the table will change the view.
+* default: `562`

+ 3 - 1
docs/extensions.md

@@ -17,4 +17,6 @@ lead: pages.extensions.lead
 
 {% tf extensions/filter.md %}
 
-{% tf extensions/keyevents.md %}
+{% tf extensions/keyevents.md %}
+
+{% tf extensions/mobile.md %}

+ 11 - 0
src/bootstrap-table.js

@@ -257,6 +257,9 @@
         onSearch: function (text) {
             return false;
         },
+        onToggle: function (cardView) {
+            return false;
+        },
         onPreBody: function (data) {
             return false;
         },
@@ -326,6 +329,7 @@
         footerFormatter: undefined,
         events: undefined,
         sorter: undefined,
+        sortName: undefined,
         cellStyle: undefined,
         searchable: true,
         cardVisible: true,
@@ -347,6 +351,7 @@
         'column-search.bs.table': 'onColumnSearch',
         'page-change.bs.table': 'onPageChange',
         'search.bs.table': 'onSearch',
+        'toggle.bs.table': 'onToggle',
         'pre-body.bs.table': 'onPreBody',
         'post-body.bs.table': 'onPostBody',
         'post-header.bs.table': 'onPostHeader'
@@ -462,6 +467,7 @@
             formatters: [],
             events: [],
             sorters: [],
+            sortNames: [],
             cellStyles: [],
             clickToSelects: [],
             searchables: []
@@ -513,6 +519,7 @@
             that.header.formatters.push(column.formatter);
             that.header.events.push(column.events);
             that.header.sorters.push(column.sorter);
+            that.header.sortNames.push(column.sortName);
             that.header.cellStyles.push(column.cellStyle);
             that.header.clickToSelects.push(column.clickToSelect);
             that.header.searchables.push(column.searchable);
@@ -657,6 +664,9 @@
 
         if (index !== -1) {
             this.data.sort(function (a, b) {
+                if(that.header.sortNames[index]) {
+                    name = that.header.sortNames[index];
+                }            	
                 var aa = a[name],
                     bb = b[name],
                     value = calculateObjectValue(that.header, that.header.sorters[index], [aa, bb]);
@@ -2105,6 +2115,7 @@
         // Fixed remove toolbar when click cardView button.
         //that.initToolbar();
         this.initBody();
+        this.trigger('toggle', this.options.cardView);
     };
 
     // BOOTSTRAP TABLE PLUGIN DEFINITION

+ 3 - 3
src/extensions/mobile/bootstrap-table-mobile.js

@@ -14,10 +14,10 @@
         if (el.options.height || el.options.showFooter) {
             setTimeout(el.resetView(), 1);
         }
-    }
+    };
 
     var changeView = function (el, width, height) {
-        if(width <= el.options.minWidth && height <= el.options.minHeight){
+        if (width <= el.options.minWidth && height <= el.options.minHeight) {
             if (!toggled) {
                 el.toggleView();
                 toggled = true;
@@ -30,7 +30,7 @@
         }
 
         resetView(el);
-    }
+    };
 
     $.extend($.fn.bootstrapTable.defaults, {
         mobileResponsive: false,