我有这个代码,我会得到记录的总数,我该怎么办? 我试过在datatables.net论坛上问一下但是没有人帮我...
tableTools: {
"sSwfPath": window.STATIC_BASE + cripts/datatable/swf/copy_csv_xls_pdf.swf",
"aButtons": [ "pdf", "csv",
"print",
{ "sExtends": "text",
"sButtonText": "TotalRecords",
"fnClick": function () {
var record_count = this.fnSettings().fnRecordsTotal();
alert(record_count);
}
}
]
}
如果我尝试使用普通字符串启动警报(例如“hello world”)它会起作用,那么问题是总记录的请求......
谢谢大家
答案 0 :(得分:1)
我认为你的范围是错误的:this
。
尝试:
var oTable = $("#myTable").dataTable({
//...
tableTools: {
"sSwfPath": "window.STATIC_BASE + cripts/datatable/swf/copy_csv_xls_pdf.swf",
"aButtons": [ "pdf", "csv",
"print",
{ "sExtends": "text",
"sButtonText": "TotalRecords",
"fnClick": function () {
var record_count = oTable.fnSettings().fnRecordsTotal();
alert(record_count);
}
}
]
}
//...
});
编辑:在您的回答之后,您可以尝试:
var oTable = $(self.table).dataTable();
代替var oTable = self.table;