jquery - DataTables warning (table id = 'IDTableName'): Cannot reinitialise DataTable -


i'm using jquery datatable in asp.net, , updatepanel (scriptmanager) . have next below error:

datatables warning (table id = 'tbverificationapplicant'): cannot reinitialise datatable.

to retrieve datatables object table, pass no argument or see docs bretrieve , bdestroy

this jquery file create table:

function datatablesexec() {          $('#tbverificationapplicant').datatable({             'bprocessing': true,             'bserverside': true,             "spaginationtype": "full_numbers",             'sajaxsource': 'listverificationdata.ashx?ddlstatusvalue=' + $("#ddlstatusclient option:selected").text(),             "fndrawcallback": function () {                 $('#tbverificationapplicant tbody tr').click(function () {                     var href = $("td:eq(0)", this).text();                     document.location.href = 'frm_verifyidentity.aspx?id=' + href;                 });             }     }); }  $(document).ready(function () {     /* initialise datatable */          datatablesexec()  }); 

but, avoid table desapear after changed dropdownlist, added next below code in code behind in web form.

protected void page_prerender(object sender, eventargs e) {     {         scriptmanager.registerstartupscript(this, this.gettype(), "_function_dummyname", "<script type='text/javascript'>datatablesexec();</script>", false);     } } 

it's working well, @ begining appear pop error.

thi part of web form:

<asp:updatepanel id="updatepanel1" runat="server">     <triggers>         <asp:asyncpostbacktrigger controlid="ddlstatusclient" eventname="selectedindexchanged" />     </triggers>     <contenttemplate>         <table id="tbverificationapplicant" class="display">                 <thead> 

when page loads ,your function datatablesexec() executed twice: once in code-behind page_prerender , once in $(document).ready function.

the error means trying make table datatable, when infact datatable.

you have rethink design here.

why neccessary registerstartupscript in prerender?

try removing either 1 of 2 datatablesexec() , problem should dissapear!


Comments

Popular posts from this blog

Unable to remove the www from url on https using .htaccess -