Deformation of editor when destroy() table
Deformation of editor when destroy() table
Hi,
I have a strange behaviour on my site. I use a dataTable which is transform on Editor instance when user clic on 'Modify' button.
To do that, I have something like that :
var editor = new $.fn.dataTable.Editor( {
...
});
$('#myTable').DataTable().destroy();
var table = $('#myTable').DataTable({
...
});
All works fine when I have one page on my table, but when I have more than one page, I have this error on destroy()
:
DataTables warning: table id=table-MAKILA2b1-2_05-associations - Requested unknown parameter '7' for row 2.
Visually, when my table is correctly generated it looks like that :
http://hpics.li/e3b36e4
If I have more than one page, it looks like that :
http://hpics.li/8fd602c
We see that a line has been moved (the first line) on the left. But just that line, the others are correctly generated. When I inspect the process with Firebug, I see on that portion :
methodScoping = function ( scope, fn, struc ) {
return function () {
var ret = fn.apply( scope, arguments );
// Method extension
_Api.extend( ret, ret, struc.methodExt );
return ret;
};
};
Each line is composed with 8 datas except the line that cause the problem (it has 7 datas). I don't understand why it isn't well composed. And if I turn the Editor on dataTable and clic again on 'Modify', it's another line that cause the problem.
Other strange thing : if I see the structure of row
I have :
- 0 : <tr#row_1.even>
- 1 : <tr#row_2.odd>
- 2 : <tr#row_3>
- 3 : <tr#row_4.odd>
- 4 : <tr#row_5.even>
- 5 : <tr#row_6.odd>
- 6 : <tr#row_7.even>
- 7 : <tr#row_8.odd>
- 8 : <tr#row_9.even>
- 9 : <tr#row_10.odd>
- 10 : <tr#row_11.even>
Row_3 hasn't 'even' class. In my case, Row_3 is the only line that is on page 2.
Does somebody have any idea about this strange behaviour ?
This question has an accepted answers - jump to answer
Answers
Can you link to a test case showing the issue so it can be debugged please.
Regarding the enabling and disabling of Editor - could you not simplify the page by just showing or hiding the Editor controls? Or is it more complicated than that?
Allan
Hi Allan,
I've send you a mail with a test case.
Just showing or hiding Editor controls isn't enough. I use many things including inline editing.
Thank's for your help.
Thank you for the e-mail.
In your code, where the Editor / DataTables code for the editable table is create you have:
The problem there is that the
prepend
is only occurring on the visible rows while the table is still a DataTable.Move the two lines which do the
prepend
to after you call thedestroy()
method.Allan
Ok it's perfect !
Thank's.