GeezerVison is showing github.com — Adding searchOnEnterKey option · fengwit/bootstrap-table@45e2489
File tree
Expand file treeCollapse file tree
Open diff view settings
src/extensions/filter-control
Expand file treeCollapse file tree
Open diff view settings
Collapse file
Copy file name to clipboardExpand all lines: src/extensions/filter-control/README.md +6Lines changed: 6 additions & 0 deletions - Display the source diff
- Display the rich diff
| Original file line number | Diff line number | Diff line change |
|---|
@@ -42,6 +42,12 @@ Dependence if you use the datepicker option: [bootstrap-datepicker](https://gith |
42 | 42 | * description: Set to true if you want to disable the control while the server is responding the data. This options will work if the sidePagination is 'server'. |
43 | 43 | * default: `false` |
44 | 44 |
|
| 45 | +### searchOnEnterKey |
| 46 | + |
| 47 | +* type: Boolean |
| 48 | +* description: Set to true to fire the search action when the user press the enter key. |
| 49 | +* default: `false` |
| 50 | + |
45 | 51 | ## Column options |
46 | 52 |
|
47 | 53 | ### filterControl |
|
Collapse file
Copy file name to clipboardExpand all lines: src/extensions/filter-control/bootstrap-table-filter-control.js +17Lines changed: 17 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
|
317 | 317 |
|
318 | 318 | if (addedFilterControl) { |
319 | 319 | header.off('keyup', 'input').on('keyup', 'input', function (event) { |
| 320 | + if (that.options.searchOnEnterKey && event.keyCode !== 13) { |
| 321 | + return; |
| 322 | + } |
| 323 | + |
| 324 | + if ($.inArray(event.keyCode, [37, 38, 39, 40]) > -1) { |
| 325 | + return; |
| 326 | + } |
| 327 | + |
320 | 328 | clearTimeout(timeoutId); |
321 | 329 | timeoutId = setTimeout(function () { |
322 | 330 | that.onColumnSearch(event); |
323 | 331 | }, that.options.searchTimeOut); |
324 | 332 | }); |
325 | 333 |
|
326 | 334 | header.off('change', 'select').on('change', 'select', function (event) { |
| 335 | + if (that.options.searchOnEnterKey && event.keyCode !== 13) { |
| 336 | + return; |
| 337 | + } |
| 338 | + |
| 339 | + if ($.inArray(event.keyCode, [37, 38, 39, 40]) > -1) { |
| 340 | + return; |
| 341 | + } |
| 342 | + |
327 | 343 | clearTimeout(timeoutId); |
328 | 344 | timeoutId = setTimeout(function () { |
329 | 345 | that.onColumnSearch(event); |
|
442 | 458 | } |
443 | 459 | }, |
444 | 460 | disableControlWhenSearch: false, |
| 461 | + searchOnEnterKey: false, |
445 | 462 | //internal variables |
446 | 463 | valuesFilterControl: [] |
447 | 464 | }); |
|