Using sum() will point to error in js file
Using sum() will point to error in js file
Hi there,
I'd like to sum up one column. Therefor I am using the sum plugin. I created a file called "plugins.js" with the following content:
https://github.com/DataTables/Plugins/blob/master/api/sum().js
Then, I used this plugin in my index.php the following way:
<script src="DataTables/plugins.js"></script>
$(document).ready(function() {
$('#example').DataTable( {
drawCallback: function () {
var api = this.api();
$( api.table().footer() ).html(
api.column( 3, {page:'current'} ).data().sum()
);
}
} );
} );
After that, my table won't load. Following error message occurs:
line 39 of plugins.js: TypeError: undefined is not an object (evaluating 'jQuery.fn.dataTable.Api')
https://www.dropbox.com/s/wvruu6gh00zsv85/sumerror.jpg?dl=0
Any idea what went wrong here?
Thank you for your help!
This question has an accepted answers - jump to answer
Answers
I'm guessing that you are loading the plug-in before loading DataTables, but without a link to a test case showing the issue that's only a guess.
Allan
Thank you very much, that was the problem!