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

Method createRow

handsontable/src/utils/ghostTable.ts:311–338  ·  view source on GitHub ↗

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

(row: number)

Source from the content-addressed store, hash-verified

309 * @returns {DocumentFragment} Returns created table row elements.
310 */
311 createRow(row: number) {
312 const rootDocument = this.hot!.rootDocument;
313 const fragment = rootDocument.createDocumentFragment();
314 const th = rootDocument.createElement('th');
315
316 if (this.hot!.hasRowHeaders()) {
317 this.hot!.view.appendRowHeader(row, th);
318
319 fragment.appendChild(th);
320 }
321
322 this.samples!.forEach((sample: SampleEntry) => {
323 arrayEach(sample.strings, (string: SampleString) => {
324 const column = string.col!;
325 const cellProperties = this.hot!.getCellMeta<CellProperties>(row, column);
326 const renderer = this.hot!.getCellRenderer(cellProperties);
327 const td = rootDocument.createElement('td');
328
329 // Indicate that this element is created and supported by GhostTable. It can be useful to
330 // exclude rendering performance costly logic or exclude logic which doesn't work within a hidden table.
331 td.setAttribute('ghost-table', '1');
332 renderer(this.hot!, td, row, column, this.hot!.colToProp(column), string.value, cellProperties);
333 fragment.appendChild(td);
334 });
335 });
336
337 return fragment;
338 }
339
340 /**
341 * Creates DOM elements for headers and appends them to the THEAD element of the table.

Callers 1

addRowMethod · 0.95

Calls 7

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

Tested by

no test coverage detected