Is there a feature to add a last row which gives the summary of the data?

Is there a feature to add a last row which gives the summary of the data?

juria_robertsjuria_roberts Posts: 11Questions: 0Answers: 0
edited March 2011 in General
Is there a feature to add a last row which gives the summary of the data? For example gives the average of all the numeric columns,total of all the numeric columns etc

Replies

  • hpachecohpacheco Posts: 19Questions: 0Answers: 0
    fnFooterCallback

    http://www.datatables.net/usage/callbacks#fnFooterCallback
  • juria_robertsjuria_roberts Posts: 11Questions: 0Answers: 0
    I am getting the bug "nRow is undefined".I refereed to this example http://www.datatables.net/examples/advanced_init/footer_callback.html. The relevant code snippet is

    [code]
    aDataSet[i]=[temp[i].keyword,temp[i].system_impression,temp[i].clicks,temp[i].conversion,temp[i].L2A,temp[i].L2R,temp[i].R2A,temp[i].RPC];

    }



    $('#dynamic'+j).html( '' );
    $('#example'+j).dataTable( {
    "bJQueryUI": true,
    "sPaginationType": "full_numbers",
    "aaData": aDataSet,
    "oLanguage": {
    "sSearch": "Search Keywords:"
    },
    "fnFooterCallback": function ( nRow, aaData, iStart, iEnd, aiDisplay ) {
    var total =0;
    for ( var i=0 ; i
  • hpachecohpacheco Posts: 19Questions: 0Answers: 0
    is there a in your table?
  • juria_robertsjuria_roberts Posts: 11Questions: 0Answers: 0
    Nope. What are the additions I need to make to my Table?
  • hpachecohpacheco Posts: 19Questions: 0Answers: 0
    you need to declare a footer

    if you inspect the demo table structure you can see it has a footer
    http://www.datatables.net/examples/advanced_init/footer_callback.html


    [code]

    Total:
    16.66% (100% total)

    [/code]
  • juria_robertsjuria_roberts Posts: 11Questions: 0Answers: 0
    Okay just wanna confirm since I'm using the javascript array method I will dynamically create a tfoot element and append it to the table.Am I on the right track?
  • allanallan Posts: 63,516Questions: 1Answers: 10,472 Site admin
    edited March 2011
    Yup - DataTables doesn't automatically create a TFOOT element. One option is when you do the $('#dynamic'+j).html(...) you could include the TFOOT in that. Alternatively you could use DOM methods to insert it just after that line, but before initialising DataTables.

    Allan
  • juria_robertsjuria_roberts Posts: 11Questions: 0Answers: 0
    Thanks It worked :) .Is it possible to have 2 footer rows for a table.If yes how do I do it?
This discussion has been closed.