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

Method getAtRow

handsontable/src/dataMap/dataSource.ts:144–214  ·  view source on GitHub ↗

* Returns a single row of the data or a subset of its columns. If a column range or `toArray` arguments are provided, it * operates only on the columns declared by the `columns` setting or the data schema. * * @param {number} row Physical row index. * @param {number} [startColumn] Starti

(row: number, startColumn?: number, endColumn?: number, toArray = false)

Source from the content-addressed store, hash-verified

142 * @returns {Array|object}
143 */
144 getAtRow(row: number, startColumn?: number, endColumn?: number, toArray = false) {
145 const getAllProps = startColumn === undefined && endColumn === undefined;
146 const { dataDotNotation } = this.hot!.getSettings();
147 let dataRow = null;
148 let newDataRow: Record<string | number, unknown> | null = null;
149
150 dataRow = this.modifyRowData(row);
151
152 if (Array.isArray(dataRow)) {
153 newDataRow = [] as unknown as Record<string | number, unknown>;
154
155 if (getAllProps) {
156 dataRow.forEach((cell: unknown, column: number) => {
157 newDataRow![column] = this.getAtPhysicalCell(row, column, dataRow);
158 });
159
160 } else {
161 // Only the columns from the provided range
162 rangeEach(startColumn!, endColumn!, (column: number) => {
163 newDataRow![column - startColumn!] = this.getAtPhysicalCell(row, column, dataRow);
164 });
165 }
166
167 } else if (isObject(dataRow) || isFunction(dataRow)) {
168 if (toArray) {
169 newDataRow = [] as unknown as Record<string | number, unknown>;
170 } else {
171 newDataRow = {};
172 }
173
174 if (!getAllProps || toArray) {
175 const rangeStart = 0;
176 const rangeEnd = this.countFirstRowKeys() - 1;
177
178 rangeEach(rangeStart, rangeEnd, (column: number) => {
179 const prop = this.colToProp(column);
180
181 if (column >= (startColumn || rangeStart) && column <= (endColumn || rangeEnd) && !Number.isInteger(prop)) {
182 const cellValue = this.getAtPhysicalCell(row, prop as string | number | DataAccessorFn, dataRow);
183
184 if (toArray) {
185 (newDataRow as unknown as unknown[]).push(cellValue);
186
187 } else if (dataDotNotation) {
188 if (newDataRow !== null) {
189 setProperty(newDataRow as Record<string, unknown>, prop as string, cellValue);
190 }
191
192 } else {
193 newDataRow![prop as string] = cellValue;
194 }
195 }
196 });
197
198 } else {
199 objectEach(dataRow as Record<string, unknown>, (value: unknown, prop: string) => {
200 const cellValue = this.getAtPhysicalCell(row, prop, dataRow);
201

Callers 2

getByRangeMethod · 0.95
CoreFunction · 0.80

Calls 11

modifyRowDataMethod · 0.95
getAtPhysicalCellMethod · 0.95
countFirstRowKeysMethod · 0.95
rangeEachFunction · 0.90
isObjectFunction · 0.90
isFunctionFunction · 0.90
setPropertyFunction · 0.90
objectEachFunction · 0.90
getSettingsMethod · 0.65
colToPropMethod · 0.65
pushMethod · 0.45

Tested by

no test coverage detected