server-side search with custom-built/manual JavaScript

server-side search with custom-built/manual JavaScript

rldean1rldean1 Posts: 141Questions: 66Answers: 1

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

  • kthorngrenkthorngren Posts: 21,328Questions: 26Answers: 4,949

    I want to try an start searching for data server-side.

    I assume you aren't trying to implement the server side processing option / protocol described here:
    https://datatables.net/manual/server-side

    I have to pass the DT AJAX success callback to the part of my app that ultimately receives the data..

    The ajax option states this about using the success function:

    success - Must not be overridden as it is used internally in DataTables. To manipulate / transform the data returned by the server use ajax.dataSrc (above), or use ajax as a function (below).

    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, and rows.add() to place the data in the Datatable. Without understanding what you are trying to do it seems the ajax is sending a request then another in success to populate the table.

    Kevin

  • rldean1rldean1 Posts: 141Questions: 66Answers: 1

    @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]

  • rldean1rldean1 Posts: 141Questions: 66Answers: 1

    @kthorngren Wow! This looks promising!

    What do you think?

    https://www.youtube.com/watch?v=LmOx0Op0n2U

  • kthorngrenkthorngren Posts: 21,328Questions: 26Answers: 4,949

    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() and rows.add() to update the table display. This might be more efficient than destroying the Datatable. But ajax.reload() may work with using ajax.data as a function.

    Kevin

This discussion has been closed.