MCPcopy Create free account
hub / github.com/handsontable/handsontable / createCol

Method createCol

handsontable/src/utils/ghostTable.ts:382–404  ·  view source on GitHub ↗

* Create table column elements. * * @param {number} column Visual column index. * @returns {DocumentFragment} Returns created column table column elements.

(column: number)

Source from the content-addressed store, hash-verified

380 * @returns {DocumentFragment} Returns created column table column elements.
381 */
382 createCol(column: number) {
383 const rootDocument = this.hot!.rootDocument;
384 const fragment = rootDocument.createDocumentFragment();
385
386 this.samples!.forEach((sample: SampleEntry) => {
387 arrayEach(sample.strings, (string: SampleString) => {
388 const row = string.row!;
389 const cellProperties = this.hot!.getCellMeta<CellProperties>(row, column);
390 const renderer = this.hot!.getCellRenderer(cellProperties);
391 const td = rootDocument.createElement('td');
392 const tr = rootDocument.createElement('tr');
393
394 // Indicate that this element is created and supported by GhostTable. It can be useful to
395 // exclude rendering performance costly logic or exclude logic which doesn't work within a hidden table.
396 td.setAttribute('ghost-table', '1');
397 renderer(this.hot!, td, row, column, this.hot!.colToProp(column), string.value, cellProperties);
398 tr.appendChild(td);
399 fragment.appendChild(tr);
400 });
401 });
402
403 return fragment;
404 }
405
406 /**
407 * Remove table from document and reset internal state.

Callers 2

addColumnMethod · 0.95
ghostTable.spec.jsFile · 0.45

Calls 5

arrayEachFunction · 0.90
getCellRendererMethod · 0.80
getCellMetaMethod · 0.65
colToPropMethod · 0.65
rendererFunction · 0.50

Tested by

no test coverage detected