我想從數據表中刪除行。這裏是我使用的數據表代碼:jQuery的數據表:如何刪除行
var aSelected = [];
oTable = $('.itemPublished').dataTable({
"bJQueryUI": true,
"sPaginationType": "full_numbers",
"bServerSide": true,
"bProcessing": true,
"sAjaxSource": "/item/datatable",
"bDeferRender": true,
"iDisplayLength":20,
"aLengthMenu": [[10, 20, 50, 75, 100, 150], [10, 20, 50, 75, 100, 150]],
"aoColumnDefs": [
{ "bSortable": false, "aTargets": [ 2, 3, 4 ] },
{ "sClass": "left", "aTargets": [ 1 ] }
],
"fnRowCallback": function(nRow, aData, iDisplayIndex) {
if (jQuery.inArray(aData.DT_RowId, aSelected) !== -1) {
$(nRow).addClass('row_selected');
}
$(nRow).addClass('gradeA');
return nRow;
}
});
我想測試一個事件來從數據表中刪除一行。該事件由datatables表DOM外部的按鈕觸發。我試着這樣做:
$('.test').live('click', function() {
oTable.fnDeleteRow(0);
});
要檢查它是否可以從表中刪除第一行,但它不會,也不會產生任何錯誤。我哪裏錯了?
http://stackoverflow.com/a/8254752/617373 – Daniel 2012-04-19 08:13:11