我在同一个ascx页面上有两个jQuery数据表。我尝试在工具栏div中插入一个超链接,在表格渲染后,它会调用后面代码中的链接。这是代码:
var SDFtable = $('#tblSDF').dataTable(
{
"scrollY": "300px",
"scrollX": true,
"scrollCollapse": true,
"paging": false,
"autowidth": true,
dom: '<"toolbar"><"filterPad"f>rti<"floatRight"B><"clear">',
//all available button options
//'copy', 'csv', 'excel', 'pdf', 'print'
buttons: {
buttons: [
{ extend: 'excel', text: 'Download this grid in Excel', exportOption: { page: 'current' }, footer: true }
]
}
});
$("div.toolbar").html('<h2><a id="aSDFExport" title="Click here to download full report" OnServerClick="ExportFundingSummaryToExcel" runat="server">SDF Pool</a></h2>');
问题是我有两个这样的代码块,每个表一个,当第二个$(&#34; div.toolbar&#34;)行运行时,它会将这个链接添加到两个数据表中。如何引用特定于正在绘制的表的文件?
提前致谢。
答案 0 :(得分:1)
试试这个:
$("#tblSDF_wrapper div.toolbar").html('<h2><a id="aSDFExport" title="Click here to download full report" OnServerClick="ExportFundingSummaryToExcel" runat="server">SDF Pool</a></h2>');
答案 1 :(得分:1)
试试这个:
$('#tblSDF').find("div.toolbar").html('<h2><a id="aSDFExport" title="Click here to download full report" OnServerClick="ExportFundingSummaryToExcel" runat="server">SDF Pool</a></h2>');