OR-types
This commit is contained in:
parent
13fc5d6a30
commit
d8a8ea77fc
5 changed files with 357 additions and 1 deletions
22
static/js/sandbox/table.js
Normal file
22
static/js/sandbox/table.js
Normal file
|
@ -0,0 +1,22 @@
|
|||
import { addElement } from "treehouse/sandbox.js";
|
||||
|
||||
export function showTable(data, schema) {
|
||||
let table = document.createElement("table");
|
||||
|
||||
let thead = table.appendChild(document.createElement("thead"));
|
||||
for (let column of schema.columns) {
|
||||
let th = thead.appendChild(document.createElement("th"));
|
||||
th.textContent = column;
|
||||
}
|
||||
|
||||
let tbody = table.appendChild(document.createElement("tbody"));
|
||||
for (let row of data) {
|
||||
let tr = tbody.appendChild(document.createElement("tr"));
|
||||
for (let column of schema.columns) {
|
||||
let td = tr.appendChild(document.createElement("td"));
|
||||
td.textContent = `${row[column]}`;
|
||||
}
|
||||
}
|
||||
|
||||
addElement(table);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue