filters done
This commit is contained in:
@@ -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');
|
||||
|
||||
Reference in New Issue
Block a user