bootstrap-table icon indicating copy to clipboard operation
bootstrap-table copied to clipboard

search does not work with pipeline extension

Open havok2063 opened this issue 3 years ago • 5 comments

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

havok2063 avatar Dec 04 '21 16:12 havok2063

Neither does the Filter Controls extension. See https://live.bootstrap-table.com/code/havok2063/9858

havok2063 avatar Dec 04 '21 17:12 havok2063

(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).

doug-the-guy avatar Apr 26 '22 18:04 doug-the-guy

This is happening after adding this data-search-on-enter-key="true" https://live.bootstrap-table.com/code/djhvscf/11360

djhvscf avatar Apr 29 '22 03:04 djhvscf

@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

UtechtDustin avatar Apr 29 '22 07:04 UtechtDustin

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':

  1. 'searchText' is used initially in params: https://github.com/wenzhixin/bootstrap-table/blob/develop/dist/bootstrap-table.js#L6658
  2. '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.

doug-the-guy avatar May 02 '22 17:05 doug-the-guy