我正在使用数据表来显示表格。单击一个按钮我想在此期间删除所有选定的行。以下是我的代码。
var anSelected = fnGetSelected( oTable );
$(anSelected).remove();
$(document).ready(function() {
var oTable = $('#example').DataTable({
"dom": 'T<"clear">lfrtip',
"tableTools": {
"sSwfPath": "extensions/TableTools/swf/copy_csv_xls_pdf.swf",
"sRowSelect": "multi",
"aButtons": [
"copy",
"print",
"csv",
"pdf",
{
"sExtends": "collection",
"sButtonText": "Save",
"aButtons": [ "csv", "xls", "pdf" ]
}
]
}
});
$('#button').click(function () {
var anSelected = fnGetSelected( oTable );
$(anSelected).remove();
});
});
答案 0 :(得分:1)
请改用以下代码:
$('#button').click(function () {
var oTT = TableTools.fnGetInstance('example');
var anSelected = oTT.fnGetSelected();
$(anSelected).remove();
});
请参阅this JSFiddle进行演示。