Browse Source

Added data-search-text

Dennis Hernández 10 years ago
parent
commit
3c3b370609
2 changed files with 16 additions and 0 deletions
  1. 7 0
      docs/_i18n/en/documentation/table-options.md
  2. 9 0
      src/bootstrap-table.js

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

@@ -230,6 +230,13 @@ The table options is defined in `jQuery.fn.bootstrapTable.defaults`.
         <td>false</td>
         <td>Enable the search input.</td>
     </tr>
+	<tr>
+        <td>searchText</td>
+        <td>data-search-text</td>
+        <td>String</td>
+        <td>''</td>
+        <td>When set search property, initialize the search text.</td>
+    </tr>
     <tr>
         <td>searchTimeOut</td>
         <td>data-search-time-out</td>

+ 9 - 0
src/bootstrap-table.js

@@ -178,6 +178,7 @@
         maintainSelected: false,
         searchTimeOut: 500,
         keyEvents: false,
+        searchText: '',
         iconSize: undefined,
         iconsPrefix: 'glyphicon', // glyphicon of fa (font awesome)
         icons: {
@@ -841,6 +842,14 @@
                     that.onSearch(event);
                 }, that.options.searchTimeOut);
             });
+
+            if (this.options.searchText !== '') {
+                $search.val(this.options.searchText);
+                clearTimeout(timeoutId); // doesn't matter if it's 0
+                setTimeout(function () {
+                    $search.trigger('keyup');
+                }, timeoutId);
+            }
         }
     };