How do you get a DataTables table Search input field to autofill with a parameter passed in a URL?
How do you get a DataTables table Search input field to autofill with a parameter passed in a URL?
I have a page which builds a page with a column like this:
<td><a href='/bin/users?phone={{ $customerPhone }}' target='_new'>{{ $customerLabel }}</a></td>
It correctly passes the phone argument to the users page as seen in the URL:
https://devel.mysite.com/bin/users?phone=303-000-0000
How do we make this autofill the DateTables Editor table Search input field so that it limits the results to the user with that phone number, 303-000-0000?
Answers
Use Javascript URLSearchParams to get the parameter and assign to a variable. Use
search.searchwith the variable to set the search term used when initializing Datatables.Kevin
You might also be interested in taking a look at this blog post from a while back which discusses this topic (albeit in a slightly different way).
Allan