Search code examples
bootstrap-table

How do I search with the "&" keyword, e.g I want food & drink


In bootstrap-table jquery (http://issues.wenzhixin.net.cn/bootstrap-table/)

How do I search with the "&" keyword, e.g I want food & drink. However, when read the source code, it has .replace for /&/ to &. Any idea I can bypass this? It is impossible to ask user to key in & in the search text box.


Solution

  • So... im still a little unclear as there is no bug in core code.

    See this fiddle which proves "&" search works fine:

    http://jsfiddle.net/dabros/x8efv6wf/1/


    If this somehow doesnt answer your needs, elaborate on exactly why.

    Then look at some extensions like multiple search, filter and filter-control:

    http://bootstrap-table.wenzhixin.net.cn/extensions/


    If still not happy, then create a custom search function. Easy to do if using server-side pagination, but possible even if client-side.

    If you fixed on using client-side (not server side pagination + search, meaning that the js does the search, not your own server code) then look at custom search.

    Relatively new feature i think, not used it myself as if i wanted a custom search i would use server-side code.

    But here it is:

    Custom search function #1956 https://github.com/wenzhixin/bootstrap-table/issues/1956

    How to search within row details? #2007 https://github.com/wenzhixin/bootstrap-table/issues/2007

    https://github.com/wenzhixin/bootstrap-table/pull/1979

    That pull requests seems most detailed, it appears full example still otw, but shouldnt be hard if you read through there.

    Though frankly, stick with plugins/extensions i listed above or use server-side code if still not happy - gives you far greater control with far simpler execution/code-maintenance.