Adding another data along to iTotalRecords

Adding another data along to iTotalRecords

ShadokShadok Posts: 19Questions: 0Answers: 0
edited September 2009 in General
Hi there,

On the serveur side, i'm calculating a sum and i'm trying to get it back and using it (sum of a column - not only the displayed lines but all the returned lines).
So I added a iTotalAmount value along with iTotalRecords, but i can't manage to read it with javascript.
How can i do it ?

I tried a few times using fnServerData or fnFooterCallback without success.

Thanks.

Replies

  • allanallan Posts: 61,822Questions: 1Answers: 10,129 Site admin
    Hi Shadok,

    I'm not quite 100% clear on what you need to do here, but if you want to pass back extra information (along with the information required by DataTables - http://datatables.net/usage/server-side ) you can do it with a custom calling function (fnServerData). Something like:

    [code]
    $(document).ready(function() {
    $('#example').dataTable( {
    "bProcessing": true,
    "bServerSide": true,
    "sAjaxSource": "../examples_support/server_processing.php",
    "fnServerData": function ( sSource, aoData, fnCallback ) {
    $.getJSON( sSource, aoData, function (json) {
    /* Do whatever additional processing you want on the callback, then tell DataTables */
    document.getElementById('whatever') = json.whatever; // etc
    fnCallback(json)
    } );
    }
    } );
    } );
    [/code]
    Regards,
    Allan
  • ShadokShadok Posts: 19Questions: 0Answers: 0
    That's exactly what i needed, thanks Allan :)
This discussion has been closed.