Pass recordsTotal back to server

Pass recordsTotal back to server

burncharburnchar Posts: 118Questions: 12Answers: 0

I'd like to send recordsTotal (and maybe other HTTP Get data) back to the server to the next REST GET request. The first GET would not have this data, but I'm not sure how to gather it once available.
Something like this (which obviously doesn't work) illustrates what I have in mind:

var rowCount = -1;
$('#example').dataTable( {
    "ajax": {
        url: "/API/myUrl?lastRowCount=" + rowCount, // Maybe this
        dataSrc: function(json) {
            rowCount = json.recordsTotal;
            return json.data;
        },
        data: function ( d ) {
            d.myKey = rowCount; // Or maybe this, then look for the value on the server
        }
    }
}

The context is avoiding SELECT COUNT(*) queries after the first, since on badly designed tables with millions of rows this can be pretty slow. When enabled, I want to be able to reasonably display 160,000,000 in "Showing 1 to 10 of 160,000,000 entries" without re-querying every time a pagination button is pressed.

Any suggestions?

This discussion has been closed.