Код: Выделить всё
Tabulator Example with Add/Delete Rows
#example-table {
width: 100%;
max-width: 800px;
height: 200px;
margin: 20px auto;
}
.action-buttons {
text-align: center;
margin: 20px 0;
}
.action-buttons button {
margin: 0 10px;
padding: 10px 20px;
font-size: 16px;
cursor: pointer;
}
Add 100 Rows
Delete Selected Rows
document.addEventListener("DOMContentLoaded", function() {
var columns = [{
title: "Name",
field: "name",
width: 150
},
{
title: "Age",
field: "age",
align: "left",
formatter: "progress"
},
{
title: "Favourite Color",
field: "color"
},
{
title: "Date Of Birth",
field: "dob",
sorter: "date",
align: "center"
},
];
var tableData = generateData(100);
window.table = new Tabulator("#example-table", {
addRowPos: "top",
data: tableData,
layout: "fitColumns",
columns: columns,
selectable: true,
});
});
function generateData(count) {
var data = [];
for (var i = 1; i 0) {
selectedRows.forEach(function(row) {
row.delete();
});
} else {
alert("No rows selected!");
}
}
Подробнее здесь: https://stackoverflow.com/questions/795 ... -virtually