Confused about fnServerData

Confused about fnServerData

CharleyCharley Posts: 66Questions: 17Answers: 0

I'm trying to implement server side processing using DWR.

With this itialization of my datatable:

        $(document).ready(function() {
            $('.ajaxDataTable').dataTable( {
                "processing": true,
                "serverSide": true,
                "ajaxSource": StyleGuideDAO.SearchDemo,
                "fnServerData": function ( sSource, aoData, fnCallback ) {
                    sSource( JSON.stringify(aoData),
                        function (json) { 
                        try{
                            fnCallback(JSON.parse(json))
                        } catch(err){alert("ERROR MESSAGE:" + err)}
                    } ); 
                }
            } );
        } );

And a dummied up SearchDemo DWR method, I can get results back. But it doesn't seem to be sending all of the expected parameters. In particular, int draw, start, and length are all missing.

Looking at the source code, it looks kind of like fnServerData is a holdover from 1.9. Is there a more correct way to override how the ajax call is done for 1.10?

This question has an accepted answers - jump to answer

Answers

  • kthorngrenkthorngren Posts: 21,301Questions: 26Answers: 4,945
    Answer ✓

    Here are some examples that show SSP with Datatables 1.10:
    https://datatables.net/examples/server_side/index.html

    In the docs you will want to look at:
    ajax
    ajax.data
    ajax.dataSrc

    Also you will probably want to look at the Server Side Processing doc:
    https://datatables.net/manual/server-side

    Please post any questions.

    Kevin

  • CharleyCharley Posts: 66Questions: 17Answers: 0

    it looks like this is how that would work in 1.10

    $(document).ready(function() {
    $('.ajaxDataTable').dataTable( {
    "processing": true,
    "serverSide": true,
    "ajax": function (data, callback, settings) {
    StyleGuideDAO.SearchDemo(JSON.stringify(data), function (json) {
    //alert(json);
    try{
    callback(JSON.parse(json))
    } catch(err){alert("ERROR MESSAGE:" + err)}
    })

                    }
                } );
            } );
    
This discussion has been closed.