fnDraw after fnGetNodes
fnDraw after fnGetNodes
SimonR
Posts: 10Questions: 0Answers: 0
Hi all,
Not really sure this is a bug, I looked on the forum before and couldn't find a duplicate so here it is:
I'm using Datatables 1.9.4 mostly to decorate my tables, bit of pagination, filtering, etc.
Some of those table have input field in them that I wish to be able to post using a regular form, problem is with the pagination not all the rows are posted since not all the rows exist in the DOM, that's not the problem mind you.
To counter that I simply moved the tables out of their respective forms and added an hidden table inside the forms, a bit of extra javascript :
[code]
$('#SaveForm').submit(function () {
$('#hiddenTable', this).append(oTable.fnGetNodes());
return true;
});
[/code]
And badaboom problem solved I have all my data server-side, now the problem is that some of the server side operation take some time and that fnGetNodes() empty the displayed table, since I doesn't look too nice I simply decided to redrew the table by using fnDraw() after fnGetNodes() so the table would stay visible while waiting for the operation to finish.
Now if I do that, fnDraw() will actually destroy the rows in my hiddenTable ! Leaving me with no data to post, and an ASP DefaultModelBinder laughing at my face !
So here you have it, I think it's kind of a double bug :
- fnGetNodes emptying the table
- fnDraw destroying DOM objects outside the the original table
A test bellow shows the problem, seems that only the data that will be displayed in the table will be destroyed in the hiddenTable
http://live.datatables.net/ujemey
I added a confirm between the fnGetNodes() and the fnDraw() to pause the process
PS : It might be my fault, if that's the case sorry about that, I'm fairly new to JS/JQ/Datatable
Not really sure this is a bug, I looked on the forum before and couldn't find a duplicate so here it is:
I'm using Datatables 1.9.4 mostly to decorate my tables, bit of pagination, filtering, etc.
Some of those table have input field in them that I wish to be able to post using a regular form, problem is with the pagination not all the rows are posted since not all the rows exist in the DOM, that's not the problem mind you.
To counter that I simply moved the tables out of their respective forms and added an hidden table inside the forms, a bit of extra javascript :
[code]
$('#SaveForm').submit(function () {
$('#hiddenTable', this).append(oTable.fnGetNodes());
return true;
});
[/code]
And badaboom problem solved I have all my data server-side, now the problem is that some of the server side operation take some time and that fnGetNodes() empty the displayed table, since I doesn't look too nice I simply decided to redrew the table by using fnDraw() after fnGetNodes() so the table would stay visible while waiting for the operation to finish.
Now if I do that, fnDraw() will actually destroy the rows in my hiddenTable ! Leaving me with no data to post, and an ASP DefaultModelBinder laughing at my face !
So here you have it, I think it's kind of a double bug :
- fnGetNodes emptying the table
- fnDraw destroying DOM objects outside the the original table
A test bellow shows the problem, seems that only the data that will be displayed in the table will be destroyed in the hiddenTable
http://live.datatables.net/ujemey
I added a confirm between the fnGetNodes() and the fnDraw() to pause the process
PS : It might be my fault, if that's the case sorry about that, I'm fairly new to JS/JQ/Datatable
This discussion has been closed.
Replies
It doesn't destroy them. It redraws them into the DataTable - which is what you've asked it to do :-).
At best you could try cloning the nodes, but in some browsers you'll lose the user entered value. The other option might be to have DataTables draw all rows, or perhaps use Ajax.
Allan
Does datatables offer a clean method to clone all the nodes that I could use instead of fnGetNodes ?
If you want to clone the nodes, you could just use `$( table.fnGetNodes() ).clone()` - but as I say, watch out for some browsers which will lose the value (IE).
Allan
Well empty table it is then, or I could ajaxify everything I guess.
Thanks Allan