浏览代码

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

Dennis Hernández 10 年之前
父节点
当前提交
c165f2d1bd

+ 4 - 3
dist/bootstrap-table.js

@@ -1475,12 +1475,13 @@
                         sprintf(' data-index="%s"', i) +
                         sprintf(' name="%s"', that.options.selectItemName) +
                         sprintf(' type="%s"', type) +
-                        sprintf(' value="%s"', item[that.options.idField]) +
+                        sprintf(' value="%s"', item[that.options.idField]),
+                        column.formatter === undefined ?
                         sprintf(' checked="%s"', value === true ||
-                            (value && value.checked) ? 'checked' : undefined) +
+                           (value && value.checked) ? 'checked' : undefined) +
                         sprintf(' disabled="%s"', !column.checkboxEnabled ||
                             (value && value.disabled) ? 'disabled' : undefined) +
-                        ' />',
+                        ' />': ' />' + value,
                         that.options.cardView ? '</div>' : '</td>'
                     ].join('');
 

+ 8 - 3
docs/_i18n/en/documentation/methods.md

@@ -279,9 +279,14 @@ The calling method syntax: `$('#table').bootstrapTable('method', parameter);`.
         <td>Toggle the card/table view.</td>
     </tr>
 	<tr>
-        <td>deleteCookie</td>
-        <td>cookie name</td>
-        <td>Delete a cookie created. You must use: 'sortOrder', 'sortName', 'pageNumber' or 'pageList'.</td>
+        <td>expandRow</td>
+        <td>index</td>
+        <td>Expand a row, the row index start with 0.</td>
+    </tr>
+	<tr>
+        <td>collapseRow</td>
+        <td>index</td>
+        <td>Collapse a row, the row index start with 0.</td>
     </tr>
     <tr>
         <td>expandRow</td>

+ 8 - 3
docs/_i18n/es/documentation/methods.md

@@ -270,9 +270,14 @@ Sintaxis para llamar a un método: `$('#table').bootstrapTable('method', paramet
         <td>Alterna la vista entre tabla y tarjeta.</td>
     </tr>
 	<tr>
-        <td>deleteCookie</td>
-        <td>cookie name</td>
-        <td>Elimina una cookie creada. Debe usar: 'sortOrder', 'sortName', 'pageNumber' o 'pageList'.</td>
+        <td>expandRow</td>
+        <td>index</td>
+        <td>Expand a row, the row index start with 0.</td>
+    </tr>
+	<tr>
+        <td>collapseRow</td>
+        <td>index</td>
+        <td>Collapse a row, the row index start with 0.</td>
     </tr>
     <tr>
         <td>expandRow</td>

+ 26 - 19
src/bootstrap-table.js

@@ -213,14 +213,16 @@
 
     var getItemField = function (item, field) {
         var value = item;
-        if (field !== undefined) {
-            var props = field.split('.');
-            for (var p in props) {
-                value = value[props[p]];
-            }
+
+        if (typeof field !== 'string' || item.hasOwnProperty(field)) {
+            return item[field];
+        }
+        var props = field.split('.');
+        for (var p in props) {
+            value = value[props[p]];
         }
         return value;
-    }
+    };
 
     // BOOTSTRAP TABLE CLASS DEFINITION
     // ======================
@@ -690,7 +692,8 @@
                 halign = sprintf('text-align: %s; ', column.halign ? column.halign : column.align);
                 align = sprintf('text-align: %s; ', column.align);
                 style = sprintf('vertical-align: %s; ', column.valign);
-                style += sprintf('width: %s%s; ', column.checkbox || column.radio ? 36 : width, unitWidth);
+                style += sprintf('width: %s; ', (column.checkbox || column.radio) && !width ?
+                    '36px' : (width ? width + unitWidth : undefined));
 
                 if (typeof column.fieldIndex !== 'undefined') {
                     that.header.fields[column.fieldIndex] = column.field;
@@ -1499,6 +1502,7 @@
                         sprintf(' disabled="%s"', !column.checkboxEnabled ||
                         (value && value.disabled) ? 'disabled' : undefined) +
                         ' />',
+                        that.header.formatters[j] ? value : '',
                         that.options.cardView ? '</div>' : '</td>'
                     ].join('');
 
@@ -1554,7 +1558,7 @@
                 item = that.data[$tr.data('index')],
                 index = $td[0].cellIndex,
                 field = that.header.fields[that.options.detailView && !that.options.cardView ? index - 1 : index],
-                colomn = that.columns[getFieldIndex(that.columns, field)],
+                column = that.columns[getFieldIndex(that.columns, field)],
                 value = getItemField(item, field);
 
             if ($td.find('.detail-icon').length) {
@@ -1565,7 +1569,7 @@
             that.trigger(e.type === 'click' ? 'click-row' : 'dbl-click-row', item, $tr);
 
             // if click to select - then trigger the checkbox/radio click
-            if (e.type === 'click' && that.options.clickToSelect && colomn.clickToSelect) {
+            if (e.type === 'click' && that.options.clickToSelect && column.clickToSelect) {
                 var $selectItem = $tr.find(sprintf('[name="%s"]', that.options.selectItemName));
                 if ($selectItem.length) {
                     $selectItem[0].click(); // #144: .trigger('click') bug
@@ -1982,12 +1986,15 @@
         }
     };
 
-    BootstrapTable.prototype.toggleRow = function (index, isIdField, visible) {
+    BootstrapTable.prototype.toggleRow = function (index, uniqueId, visible) {
         if (index === -1) {
             return;
         }
 
-        $(this.$body[0]).children().filter(sprintf(isIdField ? '[data-uniqueid="%s"]' : '[data-index="%s"]', index))[visible ? 'show' : 'hide']();
+        this.$body.find(typeof index !== 'undefined' ?
+            sprintf('tr[data-index="%s"]', index) :
+            sprintf('tr[data-uniqueid="%s"]', uniqueId))
+            [visible ? 'show' : 'hide']();
     };
 
     BootstrapTable.prototype.getVisibleFields = function () {
@@ -2201,19 +2208,17 @@
     };
 
     BootstrapTable.prototype.showRow = function (params) {
-        if (!params.hasOwnProperty('index')) {
+        if (!params.hasOwnProperty('index') || !params.hasOwnProperty('uniqueId')) {
             return;
         }
-
-        this.toggleRow(params.index, params.isIdField === undefined ? false : true, true);
+        this.toggleRow(params.index, params.uniqueId, true);
     };
 
     BootstrapTable.prototype.hideRow = function (params) {
-        if (!params.hasOwnProperty('index')) {
+        if (!params.hasOwnProperty('index') || !params.hasOwnProperty('uniqueId')) {
             return;
         }
-
-        this.toggleRow(params.index, params.isIdField === undefined ? false : true, false);
+        this.toggleRow(params.index, params.uniqueId, false);
     };
 
     BootstrapTable.prototype.getRowsHidden = function (show) {
@@ -2256,10 +2261,12 @@
     };
 
     BootstrapTable.prototype.updateCell = function (params) {
-        if (!params.hasOwnProperty('rowIndex') || !params.hasOwnProperty('fieldName') || !params.hasOwnProperty('fieldValue')) {
+        if (!params.hasOwnProperty('index') ||
+            !params.hasOwnProperty('field') ||
+            !params.hasOwnProperty('value')) {
             return;
         }
-        this.data[params.rowIndex][params.fieldName] = params.fieldValue;
+        this.data[params.index][params.field] = params.value;
         this.initSort();
         this.initBody(true);
     };

+ 1 - 1
src/extensions/editable/README.md

@@ -46,7 +46,7 @@ parameters: field, row, $el, editable
 
 Fired when an editable cell is hidden / closed.
 
-parameters: field, row, $el
+parameters: field, row, $el, reason
 
 ## The existing problems
 

+ 5 - 5
src/extensions/editable/bootstrap-table-editable.js

@@ -18,7 +18,7 @@
         onEditableShown: function (field, row, $el, editable) {
             return false;
         },
-        onEditableHidden: function (field, row, $el) {
+        onEditableHidden: function (field, row, $el, reason) {
             return false;
         }
     });
@@ -85,20 +85,20 @@
                     that.trigger('editable-save', column.field, row, oldValue, $(this));
                 });
             that.$body.find('a[data-name="' + column.field + '"]').editable(column.editable)
-                .off('shown').on('shown', function (e) {
+                .off('shown').on('shown', function (e, editable) {
                     var data = that.getData(),
                         index = $(this).parents('tr[data-index]').data('index'),
                         row = data[index];
                     
-                    that.trigger('editable-shown', column.field, row, $(this));
+                    that.trigger('editable-shown', column.field, row, $(this), editable);
                 });
             that.$body.find('a[data-name="' + column.field + '"]').editable(column.editable)
-                .off('hidden').on('hidden', function (e, editable) {
+                .off('hidden').on('hidden', function (e, reason) {
                     var data = that.getData(),
                         index = $(this).parents('tr[data-index]').data('index'),
                         row = data[index];
                     
-                    that.trigger('editable-hidden', column.field, row, $(this), editable);
+                    that.trigger('editable-hidden', column.field, row, $(this), reason);
                 });
         });
         this.trigger('editable-init');

+ 5 - 0
src/extensions/filter-control/README.md

@@ -37,6 +37,11 @@ Dependence if you use the datepicker option: [bootstrap-datepicker](https://gith
 * description: If the datepicker option is set use this option to configure the datepicker with the native options. Use this way: `data-filter-datepicker-options='{"autoclose":true, "clearBtn": true, "todayHighlight": true}'`.
 * default: `undefined`
 
+### filterStrictSearch
+* type: Boolean
+* description: Set to true if you want to use the strict search mode.
+* default: `false`
+
 ## Events
 
 ### onColumnSearch(column-search.bs.table)

+ 2 - 2
src/extensions/filter-control/bootstrap-table-filter-control.js

@@ -374,10 +374,10 @@
                     that.header.formatters[$.inArray(key, that.header.fields)],
                     [value, item, i], value);
 
-                if(thisColumn.filterStrictSearch===true){
+                if(thisColumn.filterStrictSearch){
                     if (!($.inArray(key, that.header.fields) !== -1 &&
                         (typeof value === 'string' || typeof value === 'number') &&
-                        value.toLowerCase() === fval.toLowerCase())) {
+                        value.toString().toLowerCase() === fval.toString().toLowerCase())) {
                         return false;
                     }
                 }