Prevent DataTables send Ajax request at initialize
Prevent DataTables send Ajax request at initialize
Hello, in my current project is require to use DataTables a lot and it work really great :D.
But I found one problem where some page I need to put the DataTables inside a hidden dialog
and when user click a button it will show up the dialog box with DataTables inside it.
The problem is I don't know how to prevent the DataTables to not sending an Ajax request at
initialize (because users may not open dialog at all).
I found a work around by check "sEcho" at parameter at server-side, if it is the first request then ignore it,
but that not a good thing to do, I think.
So I come to post here hope I will find a better solution.
And another thing. I don't think fnClearTable is work, at least for me. when I set boolean as false
it should clear out the table and leave it blank right? but it hadn't done anything.
But I can call it with true parameter and it can redraw the table.
Anyway thank you for this tool, it great and really help me a lot :D
and sorry for poor English.
But I found one problem where some page I need to put the DataTables inside a hidden dialog
and when user click a button it will show up the dialog box with DataTables inside it.
The problem is I don't know how to prevent the DataTables to not sending an Ajax request at
initialize (because users may not open dialog at all).
I found a work around by check "sEcho" at parameter at server-side, if it is the first request then ignore it,
but that not a good thing to do, I think.
So I come to post here hope I will find a better solution.
And another thing. I don't think fnClearTable is work, at least for me. when I set boolean as false
it should clear out the table and leave it blank right? but it hadn't done anything.
But I can call it with true parameter and it can redraw the table.
Anyway thank you for this tool, it great and really help me a lot :D
and sorry for poor English.
This discussion has been closed.
Replies
$("btn-id').click(function() {
$("#dt-id").datatables( Insert your initialization stuff here );
});
Of course I haven't tried it like this but I don't see why it wouldn't work because it won't initialize until you clicked the button or whatever you set it up like.
However, you may have to destroy the table once you do what you need to so it doesn't error out trying to reinitialize it if your app calls for that.
Hope this helps and good luck!