* 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']> )
| 31 | * @returns {unknown[]} The generated data array. |
| 32 | */ |
| 33 | function 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. |
no test coverage detected
searching dependent graphs…