Problem when destroy/recreate DataTables + Next button

Problem when destroy/recreate DataTables + Next button

inwebinweb Posts: 1Questions: 1Answers: 0
edited March 2015 in Free community support

Hello,

I need pass variables to my Ajax script. I didn't find a simple way to do this, so I decided to create a function to destroy and recreate DataTables. Everything works fine but when I use "Next" button, it freezes. When I use pagination numbers, works.

Here is my code (main pieces):

 function Filtrar() {
  $('#relatorio').DataTable().destroy();
  $('#relatorio').DataTable({
(...)
   ajax: {
     url: '/config/logs.php',
     data: function(d) {
      d.data1=$('#data1').val(),
      d.data2=$('#data2').val(),
      d.operador=$('#operador').val(),
      d.texto=$('#texto').val()
     }
   },

(...)

I need to pass this 4 variables that are composed by other fields, and reload for every new data combination (inputed by user), when I run the function. I didn't find a way to dinamically re-set the variables after the initialization block

When I run for the first time, with no previous data, everything is ok. When I run the second time, destroying previous data, if I page using numbers, everything is ok. If I page using "Next button", I can see something like:

"Showing 0,251 to 758 of 758 entries" (note: "Show 25 entries" is set)

When I debug using PHP, I realize that the "start" parameter is "025" and not "25" (second page). After this, I can use page numbers, but "Next" button is dead, no action if pressed.

Maybe it's a bug due to the padding "0" in "start" parameter? Note: I process normally and return right data, no difference.

Thank you. Sorry for my english.

This discussion has been closed.