filters done

This commit is contained in:
2026-02-26 22:56:12 +10:00
parent 4f1c66e838
commit c3996ec6c6
5 changed files with 105 additions and 106 deletions

View File

@@ -1,19 +1,26 @@
const createTable = (data, idTable) => {
const table = document.getElementById(idTable);
if (data.length == 0) {
return;
}
const header = Object.keys(data[0]);
/* создание шапки таблицы */
const headerRow = createHeaderRow(header);
table.append(headerRow);
if (!table.firstElementChild) {
const headerRow = createHeaderRow(header);
table.append(headerRow);
}
/* создание тела таблицы */
const bodyRows = createBodyRows(data);
const bodyRows = createBodyRows(data);
table.append(bodyRows);
};
const clearTable = (idTable) => {
const table = document.getElementById(idTable);
table.removeChild(table.children[1]);
if (table.children.length > 1) {
table.removeChild(table.children[1]);
}
}
const createHeaderRow = (headers) => {
@@ -26,9 +33,9 @@ const createHeaderRow = (headers) => {
return tr;
};
const createBodyRows = (rows) =>{
const createBodyRows = (rows) => {
const body = document.createElement('tbody');
rows.forEach(row =>{
rows.forEach(row => {
const rowElement = document.createElement('tr');
for (let key in row) {
const td = document.createElement('td');