Footer with Javascript Array as source of data

Footer with Javascript Array as source of data

FloppyKingFloppyKing Posts: 5Questions: 0Answers: 0
edited November 2011 in General
Probably seems like a stupid question, but how can you get your DataTable to show a footer row if you use a javascript array as your data source?

Replies

  • allanallan Posts: 63,540Questions: 1Answers: 10,476 Site admin
    You need to create it using standard DOM / jQuery methods. DataTables doesn't have a method for automatically creating the footer when using an array source - sorry. One option is simply to clone your THEAD TR and then stick it into the TFOOT - a single line in fnInitComplete should do it.

    Allan
  • arunarun Posts: 1Questions: 0Answers: 0
    Steps to add footer to Data table:

    Step 1:-

    Create the HTML string for table as well as for footer.
    htmlstr='MonthQuarterWeekQuantityGrand Total88,714';


    Step 2:-

    Draw the table only with footer.
    $('#'+divId).html(htmlstr);


    Step 3:-

    Use the actual configurations.
    $('#'+TableId).dataTable({
    "aaData":ReportData, // ReportData is javascript array contains only the report body part
    "aoColumns":columnTitles, //columnTitles contains the heading informations
    "bJQueryUI": true,
    "sPaginationType": "full_numbers"
    });
This discussion has been closed.