server-side search with custom-built/manual JavaScript
server-side search with custom-built/manual JavaScript
Hey! I'm still in the research phase, but I wanted to throw this out there:
I have a MSSQL backend, and I do everything manually with JS and jQuery in the browser with a "custom JS framework". It took me a while to understand how, but I've got AJAX calls working. Long story short, I have to pass the DT AJAX success callback to the part of my app that ultimately receives the data.... That part of my app will execute the success callback with the data received from the server.
Sooooo......
I want to try an start searching for data server-side... I presume that I can do something very similar to the strategy mentioned above...
Are there any good examples or success stories I can follow?
(I just started reading about it, thank you!)
Answers
I assume you aren't trying to implement the server side processing option / protocol described here:
https://datatables.net/manual/server-side
The
ajax
option states this about using thesuccess
function:Sounds like you will want to use
ajax.dataSrc
as a function instead.I'm not really clear on what you are trying to accomplish. Are you wanting the servers to perform a search and the results displayed in the Datatable?
If so, I would look at using an external jQuery Ajax() or getJSON to request the sorted data then use
clear()
, if appropriate, androws.add()
to place the data in the Datatable. Without understanding what you are trying to do it seems theajax
is sending a request then another insuccess
to populate the table.Kevin
@kthorngren Yes, I was thinking about using server-side processing, but i would need to write a Stored Procedure in MSSQL to handle all the parameters that are passed in from a search request... Is that even conceivable? I don't have PHP as an option
Yes, I want to perform a search, and then have DataTables show the results.
I figured server-side processing for filtering/searching was the sexy way to do it...
Otherwise, I'll just have search inputs on the web page, send that to MSSQL for querying, and then return the data for
.destroy()
or.reload()
in the DataTable in the browser... [I'm not quite sure yet]@kthorngren Wow! This looks promising!
What do you think?
https://www.youtube.com/watch?v=LmOx0Op0n2U
The youtube solution looks interesting but it doesn't look like it is setup to handle the server side processing parameters. However if you want to simplify the process you could implement that solution and send you own ajax parameters to choose the data to display.
If you are going to do your own thing you might be better off initializing Datatables once then using
clear()
androws.add()
to update the table display. This might be more efficient than destroying the Datatable. Butajax.reload()
may work with usingajax.data
as a function.Kevin