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

Method getByRange

handsontable/src/dataMap/dataSource.ts:342–374  ·  view source on GitHub ↗

* Returns source data by passed range. * * @param {object} [start] Object with physical `row` and `col` keys (or visual column index, if data type is an array of objects). * @param {object} [end] Object with physical `row` and `col` keys (or visual column index, if data type is an array of

(
    start: {row?: number, col?: number} | null = null, end: {row?: number, col?: number} | null = null, toArray = false
  )

Source from the content-addressed store, hash-verified

340 * @returns {Array}
341 */
342 getByRange(
343 start: {row?: number, col?: number} | null = null, end: {row?: number, col?: number} | null = null, toArray = false
344 ) {
345 let getAllProps = false;
346 let startRow = null;
347 let startCol = null;
348 let endRow = null;
349 let endCol = null;
350
351 if (start === null || end === null) {
352 getAllProps = true;
353 startRow = 0;
354 endRow = this.countRows() - 1;
355
356 } else {
357 startRow = Math.min(start.row!, end.row!);
358 startCol = Math.min(start.col!, end.col!);
359 endRow = Math.max(start.row!, end.row!);
360 endCol = Math.max(start.col!, end.col!);
361 }
362
363 const result: unknown[] = [];
364
365 rangeEach(startRow, endRow, (currentRow: number) => {
366 result.push((
367 getAllProps ?
368 this.getAtRow(currentRow, undefined, undefined, toArray) :
369 this.getAtRow(currentRow, startCol!, endCol!, toArray)
370 ));
371 });
372
373 return result;
374 }
375
376 /**
377 * Returns single value from the data array (intended for clipboard copy to an external application).

Callers 2

getDataMethod · 0.95
CoreFunction · 0.45

Calls 4

countRowsMethod · 0.95
getAtRowMethod · 0.95
rangeEachFunction · 0.90
pushMethod · 0.45

Tested by

no test coverage detected