Global search by choosing the fields concerned in a list in case of serverSide = false.

Global search by choosing the fields concerned in a list in case of serverSide = false.

ewayeway Posts: 3Questions: 2Answers: 0

I have a list where the user searches individually by columns.
I would also like that they can at the same time be able to search globally (global search)
I created my global search field, with a multiple selection of the columns on which the search will be carried out. The user can therefore modify this on the fly.

On the javascript side I update dtt.settings () [0] .aoColumns [column] .bSearchable (true or false)

This works in case the list serverside true but not in serverside false. In the latter case the search is carried out on all fields, even if I pass them all to false and dtt.search( val ).draw();

Do you have an idea ?

Answers

  • ewayeway Posts: 3Questions: 2Answers: 0

    I have to do dtt.ajax.reload (); after dtt.search (val); so that my bsearchable is taken into account

  • kthorngrenkthorngren Posts: 21,330Questions: 26Answers: 4,951

    Not sure I understand what you are trying to do. Sounds like you have a select list of columns. The option selected will control which column(s) the global search will search.

    dtt.settings () [0] .aoColumns [column] .bSearchable

    Directly accessing the settings is not a recommend practice as they may change. Haven't tried it but I suspect this doesn't change realtime.

    Sounds like you want to perform an OR search across the selected columns which columns().search() doesn't do as its an AND search. For client side processing I would look at creating a search plugin for this.

    While this example is not what you are describing it might give you an idea of how to get started.
    http://live.datatables.net/rosahuka/70/edit

    If you need help with this then please build a simple example (or update mine) of what you are doing and we can help build the search plugin.
    https://datatables.net/manual/tech-notes/10#How-to-provide-a-test-case

    Kevin

This discussion has been closed.