Prepopulating the Search text box
Prepopulating the Search text box
I'm passing a search from a non-DT control through my server, getting my results and rendering them to a DT grid. I'd like the string that was used for the search to be present in DT's search control after the grid is rendered.
thanks!
This question has accepted answers - jump to:
This discussion has been closed.
Answers
In your
initCompleteconfig, add this code.The table ID is "example" and the search value is "Mary"
@justSteve - What I did was create a function that would execute via
initComplete, it would look for any hash value in the URL, if it was there, it would apply that in the search. Also, whenever something is searched for, it will change the #hash value, that way you can copy and paste the URL and the search will automatically be applied..Oh, and as you can see, I applied the nifty little searchHighlight plugin I found on here, created by Bartek Szopka. Iv you dont wait it, just remove the
searchHighlight: true,line. I like it because it kinda makes the viewer realize "Hey, im viewing a table that has filters applied to it!"Loving the idea of cutting/pasting searches.
Its definitely more useful than I even thought it would be. People just filter the table and copy/paste it in emails, and the exact results are shown. I was thinking about doing the same thing for sorting and maybe even page length.
Did you end up using it? Just curious
@justSteve I created a function to update the hash with the page, page length, ordering and search string.
re: am i using...? - absolutely and with many thanks!
I think im gonna make it a DT plugin, simple enough. Just include the script, then something like
Or..
What do you think? would it be useful?
Ive actually got a few other DT functions that I made to be able to work on just about any table, I might turn some of the others into plugins as well, check the functions out here, the comments should be description enough
@justSteve - You got me to make my first DT Plugin!
Thread here