MCPcopy
hub / github.com/handsontable/handsontable / buildNullData

Function buildNullData

handsontable/src/dataMap/replaceData.ts:33–62  ·  view source on GitHub ↗

* Builds the initial empty dataset rows when `data` is `null`. * * @param {HotInstance} hotInstance The Handsontable instance. * @param {DataMap} newDataMap The newly created DataMap instance. * @param {object} tableMeta The current table settings. * @returns {unknown[]} The generated data arra

(
  hotInstance: HotInstance,
  newDataMap: DataMap,
  tableMeta: ReturnType<HotInstance['getSettings']>
)

Source from the content-addressed store, hash-verified

31 * @returns {unknown[]} The generated data array.
32 */
33function buildNullData(
34 hotInstance: HotInstance,
35 newDataMap: DataMap,
36 tableMeta: ReturnType<HotInstance['getSettings']>
37): unknown[] {
38 const dataSchema = newDataMap.getSchema();
39 const data: unknown[] = [];
40
41 for (let r = 0, rlen = tableMeta.startRows as number; r < rlen; r++) {
42 let row;
43
44 if ((hotInstance.dataType === 'object' || hotInstance.dataType === 'function') && tableMeta.dataSchema) {
45 row = deepClone(dataSchema);
46
47 } else if (hotInstance.dataType === 'array') {
48 row = deepClone((dataSchema as unknown[])[0]);
49
50 } else {
51 row = [];
52
53 for (let c = 0, clen = tableMeta.startCols as number; c < clen; c++) {
54 row.push(null);
55 }
56 }
57
58 data.push(row);
59 }
60
61 return data;
62}
63
64/**
65 * Loads new data to Handsontable.

Callers 1

replaceDataFunction · 0.85

Calls 3

deepCloneFunction · 0.90
getSchemaMethod · 0.65
pushMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…