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/)来表明我的解决方案有效。 –