TotalRecordCount by Server

TotalRecordCount by Server

grizzmockgrizzmock Posts: 1Questions: 1Answers: 0

Hi There,

i am using the datatable with server side processing and a custome ajax-function:

    this.table = tableElement.DataTable({
        ajax: function(data, callback, settings) {
                callback({ data: getDataObjectArrayFromServer(data) });
        },
        ...

My backend consists of some REST Webservices which handle the paging/sorting/filtering but i can't find any information how i can make the frontend paging work correctly.

The table displays:

Showing 0 to 0 of 0 entries (filtered from NaN total entries)

how can i set these information (the total number for example by an extra HTTP Call)?

Thanks a lot
Chris

Answers

  • glendersonglenderson Posts: 231Questions: 11Answers: 29

    What is contained in your getDataObjectArrayFromServer data?

    Is it returning the necessary values that dataTables is seeking?

    your data needs to contain the elements for
    "recordsTotal", "recordsFiltered", and then the actual "data"

    I tend to include this all as part of the JSON response from the server.

    { "recordsTotal": 2000,
    "recordsFiltered": 127,
    "data": [ .... My data for the n length of data per page ... ]
    }
    
This discussion has been closed.