MCPcopy
hub / github.com/handsontable/handsontable / get

Method get

handsontable/src/dataMap/dataMap.ts:813–880  ·  view source on GitHub ↗

* Returns single value from the data array. * * @param {number} row Visual row index. * @param {number} prop The column property. * @returns {*}

(row: number, prop: string | number)

Source from the content-addressed store, hash-verified

811 * @returns {*}
812 */
813 get(row: number, prop: string | number) {
814 const physicalRow = this.hot!.toPhysicalRow(row);
815
816 let dataRow: Record<string | number, unknown> = this.dataSource![physicalRow] as Record<string | number, unknown>;
817 // TODO: To remove, use 'modifyData' hook instead (see below)
818 const modifiedRowData = this.hot!.runHooks('modifyRowData', physicalRow);
819
820 dataRow = typeof modifiedRowData !== 'number' ? modifiedRowData as Record<string | number, unknown> : dataRow;
821 //
822
823 const { dataDotNotation } = this.hot!.getSettings();
824 let value: unknown = null;
825
826 // try to get value under property `prop` (includes dot)
827 if (dataRow && hasOwnProperty(dataRow, prop)) {
828 value = dataRow[prop];
829
830 } else if (dataDotNotation && typeof prop === 'string' && prop.indexOf('.') > -1) {
831 let out: Record<string, unknown> = dataRow;
832
833 if (!out) {
834 return null;
835 }
836
837 const sliced = prop.split('.');
838
839 for (let i = 0, ilen = sliced.length; i < ilen; i++) {
840 out = out[sliced[i]] as Record<string, unknown>;
841
842 if (typeof out === 'undefined') {
843 return null;
844 }
845 }
846
847 value = out;
848
849 } else if (typeof prop === 'function') {
850 value = (prop as (row: unknown) => unknown)(this.dataSource!.slice(physicalRow, physicalRow + 1)[0]);
851 }
852
853 const visualColumnIndex = this.propToCol(prop);
854 const physicalColumn = typeof visualColumnIndex === 'number'
855 ? this.hot!.toPhysicalColumn(visualColumnIndex)
856 : null;
857
858 if (isUnsignedNumber(physicalRow) && isUnsignedNumber(physicalColumn)) {
859 value = getValueGetterValue(
860 value,
861 this.metaManager!.getCellMeta(physicalRow, physicalColumn, {
862 visualRow: row,
863 visualColumn: visualColumnIndex,
864 skipMetaExtension: true
865 })
866 );
867 }
868
869 if (this.hot!.hasHook('modifyData')) {
870 const valueHolder = createObjectPropListener(value);

Callers 15

getCopyableMethod · 0.95
RendererComponent2Function · 0.45
HotTableContextProviderFunction · 0.45
stringifyToJSONFunction · 0.45
cleanupContainerMethod · 0.45
sweepDetachedViewsMethod · 0.45
replaceCellContentMethod · 0.45
registryForMethod · 0.45
renderComponentMethod · 0.45
fetchGitHubVersionsFunction · 0.45

Calls 13

propToColMethod · 0.95
hasOwnPropertyFunction · 0.90
isUnsignedNumberFunction · 0.90
getValueGetterValueFunction · 0.90
createObjectPropListenerFunction · 0.90
toPhysicalRowMethod · 0.80
toPhysicalColumnMethod · 0.80
hasHookMethod · 0.80
isTouchedMethod · 0.80
runHooksMethod · 0.65
getSettingsMethod · 0.65
getCellMetaMethod · 0.65

Tested by 3

RendererComponent2Function · 0.36
setFunction · 0.36
createContextFunction · 0.36