Version 1.9.4 Pagination Displaying in Wrong Element

Version 1.9.4 Pagination Displaying in Wrong Element

MattSypMattSyp Posts: 3Questions: 0Answers: 0
edited July 2013 in General
I am updating datatables based on a custom global filter.

I initialize the table like this

[code]

$.extend(true, $.fn.dataTable.defaults, {
"bProcessing": true,
"bServerSide": false,
"sDom": 'Rlrtip',
"bSortCellsTop": true,
"bStateSave": true,
"bLengthChange": false,
"iDisplayLength": 20,
"bFilter": true,
"bShowGlobal": false
});

var oTable = $('#tblMainList').DataTable({
"sDom": 'lrtip',
"bStateSave": false,
"iDisplayLength": 55,
"sAjaxSource": AjaxURL,
"aoColumns": [
{
"sWidth": "100px",
"mData": "Key",
"bSortable": false,
"sDefaultContent": ' ',
"mRender": function (data, type, full) {
var action = 'myaction';
return action;
}
},
{ "mData": "Field1" },
{ "mData": "Field2" }
],
"fnDrawCallback": function () {
SomeFunction();
}
});
[/code]

Then I refresh it like this

[code]
$('.page-filter').click(function (event) {
event.preventDefault();

$.getJSON(AjaxUpdateURL, '', function (data) {
oTable.fnClearTable();
oTable.fnAddData(data.aaData);
});

});
[/code]

The problem is I have a UL on the page as well and anytime I refresh datatables, and the other UL has a LI in it, the links for pages 2-X display in my other UL.

Replies

  • allanallan Posts: 63,075Questions: 1Answers: 10,384 Site admin
    Are you using any paging plug-ins? Can you link me to the test page showing the error - I've not seen this one before.

    Thanks,
    Allan
  • MattSypMattSyp Posts: 3Questions: 0Answers: 0
    Hi Allen,

    Thank you for getting back to me so quick. I am using the foundation plugin which apparently did some processing of the paging and that is where the issue was. Below is the for loop that hands the paging in dataTables.foundation.js. What happened is the an[i] was being lost during the $.each. To fix this, I set a variable currentan at the top of the for loop and use that instead of the an[i]. This persisted through the process and fixed the issue.

    [code]
    for ( i=0, ien=an.length ; i
  • allanallan Posts: 63,075Questions: 1Answers: 10,384 Site admin
    Ah! Nice one - thanks for this I'll put the fix into the git repo :-)

    Regards,
    Allan
  • allanallan Posts: 63,075Questions: 1Answers: 10,384 Site admin
    Fix in git now: https://github.com/DataTables/Plugins/commit/2adba8a . Thanks again for posting this.

    Allan
  • MattSypMattSyp Posts: 3Questions: 0Answers: 0
    No problem Allan. Great tool and I'm glad I could make it a little better.
This discussion has been closed.