Quantcast
Channel: Recent Discussions — DataTables forums
Viewing all articles
Browse latest Browse all 82435

column Total for all pages

$
0
0
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

<script type="text/javascript">
	$(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<aoData.length ; i++ )
		                {
		                   iBalance += aoData[i][4]*1;
		                }		                
		                /* Modify the footer row to match what we want */
		                var nCells = nRow.getElementsByTagName('th');		             
		         	nCells[4].innerHTML = parseFloat(iBalance).toFixed(2);       
		},				
	    });     
	} );
</script>

Any help will be appreciated. thanks

Viewing all articles
Browse latest Browse all 82435

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>