gpt4 book ai didi

jquery - 数据表警告(表 ID = 'IDTableName'): Cannot reinitialise DataTable

转载 作者:行者123 更新时间:2023-12-01 02:02:40 25 4
gpt4 key购买 nike

我在 ASP.NET 中使用 Jquery Datatable 和 UpdatePanel (scriptManager) 。我有以下错误:

DataTables warning (table id = 'tbVerificationApplicant'): Cannot reinitialise DataTable.

To retrieve the Datatables object for this table, pass no argument or see the docs for bRetrieve and bDestroy

这是创建表的 Jquery 文件:

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 the DataTable */

DatatablesExec()

});

但是,为了避免在更改下拉列表后表格消失,我在 Web 表单的代码后面添加了下面的代码。

protected void Page_Prerender(object sender, EventArgs e)
{
{
ScriptManager.RegisterStartupScript(this, this.GetType(), "_function_dummyname", "<script type='text/javascript'>DatatablesExec();</script>", false);
}
}

它运行良好,但在开始时会弹出一个错误消息。

这是网络表单的一部分:

<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<Triggers>
<asp:AsyncPostBackTrigger ControlID="ddlStatusClient" EventName="SelectedIndexChanged" />
</Triggers>
<ContentTemplate>
<table id="tbVerificationApplicant" class="display">
<thead>

最佳答案

这也让我抓狂,所以我想我应该添加适合我的解决方案。

如果您发送的任何 Ajax 请求在表格的某些元素中响应,则需要在表格配置中设置

bRetrieve: true 

SUVASH'S BLOG explains:

There is an another scenario ,say you send more than one ajax request which response will access same table in same template then we will get error also.In this case fnDestroy method doesn’t work properly because you don’t know which response comes first or later.Then you have to set bRetrieve TRUE in data table configuration.That’s it.

关于jquery - 数据表警告(表 ID = 'IDTableName'): Cannot reinitialise DataTable,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18489663/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com