浏览代码

Fix #41: Non case sensitive search in client side.

zhixin 11 年之前
父节点
当前提交
8c3f6530ae
共有 1 个文件被更改,包括 4 次插入3 次删除
  1. 4 3
      src/bootstrap-table.js

+ 4 - 3
src/bootstrap-table.js

@@ -411,7 +411,7 @@
 
 
     BootstrapTable.prototype.onSearch = function (event) {
     BootstrapTable.prototype.onSearch = function (event) {
         var that = this,
         var that = this,
-            text = $(event.currentTarget).val();
+            text = $.trim($(event.currentTarget).val());
 
 
         if (text === this.searchText) {
         if (text === this.searchText) {
             return;
             return;
@@ -421,8 +421,9 @@
         if (this.options.sidePagination !== 'server') {
         if (this.options.sidePagination !== 'server') {
             this.data = $.grep(this.options.data, function (item) {
             this.data = $.grep(this.options.data, function (item) {
                 for (var key in item) {
                 for (var key in item) {
-                    if (typeof item[key] === 'string' && item[key].indexOf(that.searchText) !== -1) {
-                        return true;
+                    if (typeof item[key] === 'string' &&
+                        item[key].toLowerCase().indexOf(that.searchText.toLowerCase()) !== -1) {
+                            return true;
                     }
                     }
                 }
                 }
                 return false;
                 return false;