Can I use the search() functionality to provide an alternate SQL statement to perform the search?

Can I use the search() functionality to provide an alternate SQL statement to perform the search?

menashemenashe Posts: 150Questions: 35Answers: 1

Link to test case:
Debugger code (debug.datatables.net):
Error messages shown:
Description of problem:

Answers

  • kthorngrenkthorngren Posts: 20,144Questions: 26Answers: 4,736

    One option, if using ajax, might be to use ajax.data as a function to send search parameters to the server. Use ajax.reload() to fetch a new set of data with the parameters. See this example.

    If this doesn't help then please provide details of your Datatables environment and what you would like to do.

    Kevin

  • menashemenashe Posts: 150Questions: 35Answers: 1

    Kevin,
    I do not think that will help.
    Asd a simple example:
    I have table A, which contains "Item".
    Table B, contains "Item_ID" and "Description".
    My DataTable display data from table A, but when searching (filtering) I would like to be able to search on additional fields that are only in table B--such as Description--and display the corresponding record(s) from table A.

  • rf1234rf1234 Posts: 2,801Questions: 85Answers: 406
    edited March 2023

    You would just join both tables as input for your data table and hide the columns "Item_ID" and "Description" in your data table display. Done.

    I have just tested it: The search field works with hidden columns as well. Since search is performed client side you MUST download those extra columns to the client (unless you are using serverSide which I would only recommend if absolutely required due to its multiple negative implications).

Sign In or Register to comment.