TableHeader.js 767 B

1234567891011121314151617181920212223
  1. export default class TableHeader {
  2. constructor(columns) {
  3. this.columns = columns;
  4. }
  5. render() {
  6. const tr = document.createElement('tr');
  7. const colgroup = document.createElement('colgroup');
  8. this.columns.forEach((column) => {
  9. const th = document.createElement('th');
  10. const col = document.createElement('col');
  11. th.setAttribute('data-column', column.column);
  12. col.setAttribute('data-column', column.column);
  13. th.innerHTML = column.label
  14. tr.appendChild(th);
  15. colgroup.appendChild(col);
  16. });
  17. const thead = document.createElement('thead');
  18. thead.appendChild(tr);
  19. return {colgroup : colgroup, thead : thead };
  20. }
  21. }