column Total for all pages

column Total for all pages

mazammazam Posts: 4Questions: 0Answers: 0
edited March 2014 in General
I am tring to use DataTables in my test environment for my companies website. I have implemented it successfully by following the examples of server side processing. But I am having difficulty is showing column total of all pages. I tried to use fnFooterCallBack function as described but it only shows the total of current page rows for that column not all rows on all pages for that column. e.g if I have 10 record in total with column total of 600.00 and if I am displaying 5 in one page then I get total of 375.00 and on the second page it shows total of 225.00.

I tried to find solution from all replies in this forum for this issue but couldn't able to get any solution. According to example of fnFooterCallBack function "* Calculate the total market share for all browsers in this table (ie inc. outside the pagination)" but it doesn't work in this way. It only calculates the current page.

How can I display 600.00 regardless of displayed records?

Here is my code from the example

[code]

$(document).ready(function() {
/*
* Initialse DataTables, with no sorting on the 'details' column
*/
var oTable1 = $('#customerdata').dataTable( {
"sPaginationType": "full_numbers",
"oLanguage": {
"sInfoFiltered": ""
},
"aaSorting": [[ 3, "desc" ]],
"bProcessing": true,
"bServerSide": true,
"sAjaxSource": "../wp-content/themes/mytheme/customertable.php?cust_id=<?php echo $customer_id; ?>",
"fnFooterCallback": function ( nRow, aoData, iStart, iEnd, aiDisplay ) {
/*
* Calculate the total market share for all browsers in this table (ie inc. outside
* the pagination)
*/
var iBalance= 0;
for ( var i=0 ; i

Replies

  • mazammazam Posts: 4Questions: 0Answers: 0
    I have solved it myself and want to share the solution if some is having the same issue. The problem in my code is
    "bProcessing": true,
    "bServerSide": true,
    I just removed these option and my table is working as required.
  • allanallan Posts: 63,687Questions: 1Answers: 10,500 Site admin
    > "bServerSide": true,

    Yup - that's the issue. The whole point of server-side processing is that it only loads the data needed for the current view. So the data you are summing is the data you can see only.

    You want to use client-side processing where all data is loaded up front.

    Allan
  • mazammazam Posts: 4Questions: 0Answers: 0
    Thanks for your reply Allan.
This discussion has been closed.