Can't able to redraw Datatable
Can't able to redraw Datatable
dharmeshpatel82
Posts: 15Questions: 2Answers: 0
Hello,
I have a Datatable on page, and Also I put a link to reload this Datatable (User interaction is required to refresh Datatable, and for some reason I have to put refresh link outside of Datatable Division.) and this is a ServerSide Datatable.
On page load I got my Datatable loaded but when I clicked on refresh link It is not working.
My refresh link click event is :
[code]
$(document).on('click', '#refreshLinkId', function (event) {
event.preventDefault();
var tblId = $(this).attr("type") + "_wrapper";//getting Datatable ID
var table = $(tblId).dataTable();
table.fnDraw();
$('#refreshConfirmDialogId').data('tableInst', table );
$('#refreshConfirmDialogId').dialog("open");
});
[/code]
When I click the link I got this Warning :
[quote]
DataTables warning: Attempted to initialise DataTables on a node which is not a table: DIV
[/quote]
and got this error too when I try to call fnDraw or any other internal Method of DataTable instance(found through Firebug) :
[quote]
TypeError: a is null
[Break On This Error]
...Sort ? O(a, a.oPreviousSearch) : a.oFeatures.bFilter ? K(a, a.oPreviousSearch) :...
[/quote]
Does anybody knows, whats wrong with my code? Also I want to redraw my Datatable with extra server param on refresh link click which will be added to Ajax Request to get Modification in Database and return new Data, I do not know how can I do that?
Please let me know if there is a solution for this?
Thank you.
I have a Datatable on page, and Also I put a link to reload this Datatable (User interaction is required to refresh Datatable, and for some reason I have to put refresh link outside of Datatable Division.) and this is a ServerSide Datatable.
On page load I got my Datatable loaded but when I clicked on refresh link It is not working.
My refresh link click event is :
[code]
$(document).on('click', '#refreshLinkId', function (event) {
event.preventDefault();
var tblId = $(this).attr("type") + "_wrapper";//getting Datatable ID
var table = $(tblId).dataTable();
table.fnDraw();
$('#refreshConfirmDialogId').data('tableInst', table );
$('#refreshConfirmDialogId').dialog("open");
});
[/code]
When I click the link I got this Warning :
[quote]
DataTables warning: Attempted to initialise DataTables on a node which is not a table: DIV
[/quote]
and got this error too when I try to call fnDraw or any other internal Method of DataTable instance(found through Firebug) :
[quote]
TypeError: a is null
[Break On This Error]
...Sort ? O(a, a.oPreviousSearch) : a.oFeatures.bFilter ? K(a, a.oPreviousSearch) :...
[/quote]
Does anybody knows, whats wrong with my code? Also I want to redraw my Datatable with extra server param on refresh link click which will be added to Ajax Request to get Modification in Database and return new Data, I do not know how can I do that?
Please let me know if there is a solution for this?
Thank you.
This discussion has been closed.
Replies
Beyond that, please link to a test case showing the issue.
Allan
Thank you for the note, It absolutely gave me a direction. I realize we can call initialized table anywhere in the page and unless it is destroyed.
My Stupid mistake was, I was selecting Table Div instead I should select Table. I just had to remove "_wrapper" from Table id, where "_wrapper is Table Div Id." :)
My apologies. Sometimes small mistake is there but I can't see. Very Stupid.
But your note confirms me that we can get instance of table anywhere within the reach. Thank you.
Now I just need to figure out how to add extra param to server request before re-draw table.
Thank you very much Allan for your help. Really appreciated.
Dharmesh Patel