bootstrap-table
bootstrap-table copied to clipboard
search does not work with pipeline extension
Bootstraptable version(s) affected
1.19.1
Description
The search functionality does not work when used with the Pipeline extension.
Example(s)
See example at https://examples.bootstrap-table.com/index.html#extensions/pipeline.html. Typing in the search does not update the results.
Possible Solutions
No response
Additional Context
No response
Neither does the Filter Controls extension. See https://live.bootstrap-table.com/code/havok2063/9858
(pipeline extension developer)
As noted in the documentation for this extension, searching will invalidate the internal cache and initiate a new server side request. The 'searchText' POST parameter will contain the search box text so your server side code must filter on that.
I recommend you use data-search-on-enter-key="true"
unless you want a ajax request on every key press.
It's been a while since I developed this, but I believe I did not allow searching on the client side cache because it could give inaccurate results since it would only be filtering on up to cacheSize rows, not the whole data set (which the user is most likely unaware of).
This is happening after adding this data-search-on-enter-key="true" https://live.bootstrap-table.com/code/djhvscf/11360
@djhvscf do you tested it locally ?
Because the used url https://examples.wenzhixin.net.cn/examples/bootstrap_table/data
ignores the search parameter searchText
, the correct one would be search
.
Example:
Not working: https://examples.wenzhixin.net.cn/examples/bootstrap_table/data?searchText=Item 20
Working: https://examples.wenzhixin.net.cn/examples/bootstrap_table/data?search=Item 20
https://examples.wenzhixin.net.cn/examples/bootstrap_table/data?search=Item 20
The pipeline extension overrides the base initServer function. In pipeline, the search parameter is always 'searchText'.
Looking at the base initServer function, it uses both 'searchText' and 'search':
- 'searchText' is used initially in params: https://github.com/wenzhixin/bootstrap-table/blob/develop/dist/bootstrap-table.js#L6658
- 'search' is used when queryParamTypes == 'limit': https://github.com/wenzhixin/bootstrap-table/blob/develop/dist/bootstrap-table.js#L6679 (note also sortName is changed to sort and sortOrder is changed to order in this case)
I'm not sure why this changes in 2.