Totals Row broken Pagination
Totals Row broken Pagination
NickyJ
Posts: 1Questions: 0Answers: 0
Firstly I have to say this table plugin is great, great functionality.
I have a server side script table, with additional date range filters. All working fine. I have since added the footer callback to total a column, just per example http://datatables.net/examples/advanced_init/footer_callback.html
Now this breaks the pagination as I get a Javascript error of
[quote]aaData[aiDisplay[i]] is undefined [/quote]
Using : [code]
"fnFooterCallback": function ( nRow, aaData, iStart, iEnd, aiDisplay ) {
var iTotalMarket = 0;
for ( var i=0 ; i
I have a server side script table, with additional date range filters. All working fine. I have since added the footer callback to total a column, just per example http://datatables.net/examples/advanced_init/footer_callback.html
Now this breaks the pagination as I get a Javascript error of
[quote]aaData[aiDisplay[i]] is undefined [/quote]
Using : [code]
"fnFooterCallback": function ( nRow, aaData, iStart, iEnd, aiDisplay ) {
var iTotalMarket = 0;
for ( var i=0 ; i
This discussion has been closed.
Replies
> Firstly I have to say this table plugin is great, great functionality.
Thanks!
> Feel I may be missing something pretty obvious, any advice appreciated.
Its not that obvious actually :-). The example above works for client-side processing since DataTables stores a cache of all data on the client-side (which is what aaData is, and aiDisplay is pointing at). This doesn't work on server-side processing since there is no client-side store of the full data set - only the current page. This all you need to do here is loop over aaData - since that's all the data for the current page.
[code]
for ( var i=0 ; i
George
I'm not sure where where aaData[n] is, as it isn't in the above code. Can you link me to your page please?
Allan
[code]
var oTable = $('#example').dataTable({
"sAjaxSource" : "someController.someAction",
"fnFooterCallback": function (nFoot, aaData, iStart, iEnd, aiDisplay ) {
alert(aaData[1]);
},
"aoColumns" : [
{
"mDataProp" : "field1"
},
{
"mDataProp" : "field2",
"sWidth" : "20%",
"sClass" : "center"
},
{
"mDataProp" : "field3",
"sWidth" : "20%",
"sClass" : "center"
},
{
"mDataProp" : "field4",
"sWidth" : "20%",
"sClass" : "center"
}
]
});
[/code]
Looks like I missed something, and the aaData[1] will return [object Object]. By the way, I enjoy this plugin(Datatables) so much. Thank you.
It would do :-). Its an array of arrays or an array of objects depending on your data source. So aaData[1] is just the second element. I'd suggest you use console.log( aaData ); rather than alert() as that will let you actually see what is in the object.
Allan
Allan
[quote]
0
GET http://localhost:9000/someController/someAction?_=1336032307777 200 OK 153ms
332
[/quote]
It return me a correct count. And if I do console.log( aaData[1] ), this will get returned:
[quote]
Object { field1="value1", field2="value2", field3="value3", .....}
[/quote]
And those fields and values are all correct.
But if I do console.log( aaData[1].field1] ), it will return:
[quote]
aaData[1] is undefined
[/quote]
Thank you!
From your description that looks like it should work to me. I'm fraud that to offer any further assistance I'd need to be able to actually see the page, so I can see what is going wrong with it.
Allan
I used [code]oTable.fnGetData(aiDisplay[x],y)[/code], where x, y are integers, to work around this problem. But still want to know how I can't use aaData[x].field, since I have the aaData, at least for the current page.
Allan
George
Allan