1
我想從表中刪除多行,並且我已經使用下面的代碼,但不起作用。
我使用DataTables v1.10.9
。從表中刪除多選的行
$('#del_Btn').on('click', function() {
// 'table' is the instance of table object
table.row('.selected').remove().draw(false);
}
全碼:
$('#del_MembersBtn').on('click', function() {
if (confirm('Do you want to remove the selected items ?') === true) {
var selRows = RemoveFromGroupTable.rows({selected: true}).data().pluck(0); // return an object contains selected rows
var selRowsLength = selRows.length;
var rows = new Array();
for (i = 0; i < selRowsLength; i++) {
rows.push(selRows[i]);
}
// remove the selected rows from table
RemoveFromGroupTable.rows('.selected').remove().draw(false);
var inputData = {};
inputData.selectdRows = rows;
inputData.submit = Math.floor(Math.random() * 10) + 1;
$.post(myProp.base_url + 'directory/class/method', inputData, function (outputData) {
if (outputData.submit == outputData.submit) {
tips();
}
}, 'json');
}
} });
我能做些什麼來移除多個選定的行?
謝謝,但不幸的是,它不起作用,它只是從選定的項目中刪除顏色。我已更新我的問題,請參閱我的完整代碼。 –
@LionKing,添加了[demo](https://jsfiddle.net/9v0wofbh/)來表明我的解決方案有效。 –