.draw() - not working. What do I do wrong?
.draw() - not working. What do I do wrong?
edwardc
Posts: 30Questions: 11Answers: 0
When the value in #table2 is modified in editor, #table1 needs to redraw as some values has change.
Therefore I have the code:
var editor = new $.fn.dataTable.Editor({
ajax: 'php/page...[some_link].... .php,
table: '#table2',
fields: [
{
"label": "something",
"name": "something"
}
]
}).on('submitComplete', function () {
var my_table = $('#tabel1').DataTable();
// my_table.ajax.reload(); - also tried as I thought it requires to refresh with data from server
my_table.draw();
});
But no success. What do I do wrong?
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
Is
my_table
server-side processing? If not you would need to useajax.reload()
like in your commented out line. That will load the new data from the server.If that isn't working for you, we'd need a link to the page showing the issue.
Allan
it is server-side processing. Must have full reload as it also perform javascript math.
A bit difficult to send a link as it is part of a larger project and I must pass also user-names and passwords in order to access it. Maybe on email?
It seems that, for some reasons, I can not retrieve it correct. console.log(my_table) show the object is empty, lenght is 0.
I check the syntax. I even copy/paste the name again, just to be sure.
I have used in another page the ajax.reload and draw() and they work perfectly but the DataTable instance was in the same js.
The refresh was required due to some server processing that was happening after the editor was finish (on submitSuccess). In this exemple I need to refresh a table after a different one was altered.
So do you get any error messages when you try to access
my_table
?I'm afraid that without a link to a page showing the issue, there is really not much help I can offer, particularly, since as you note, it works on a different page.
Allan
I sent a message with login details and how to reproduce the issue.
Please let me know if you need something else.
Got it!!
In fact the draw() was performed but I was displaying the old values.
I use a cache system to prevent over-loading on each draw. The cache variable needed to be reset in order to update.
Thanks for the update - great to hear you've got it working. Sorry I didn't get a chance to reply to your PM before you got it working.
Allan