MCPcopy Create free account
hub / github.com/apitable/apitable / getField

Method getField

packages/widget-sdk/src/script/datasheet.ts:207–221  ·  view source on GitHub ↗

* Get the specified field in the datasheet. * * @param fieldKey Name or ID of the field. * * @returns * * #### Example * ```js * console.log(myDatasheet.getField('fieldName')); // => Field * console.log(myDatasheet.getField('fldxxxxxx')); // => Field * ```

(fieldKey: string)

Source from the content-addressed store, hash-verified

205 * ```
206 */
207 public getField(fieldKey: string) {
208 const state = this.wCtx.widgetStore.getState() as unknown as IReduxState;
209 const fieldDataMap = Selectors.getFieldMap(state, this.datasheetId)!;
210 let fieldId = fieldKey;
211
212 if (!fieldDataMap[fieldId]) {
213 const field = Object.values(fieldDataMap).find(({ name }) => fieldKey === name);
214
215 if (field != null) {
216 fieldId = field.id;
217 }
218 }
219 const field = Selectors.getField(state, fieldId, this.datasheetId);
220 return new Field(this.datasheetId, this.wCtx, field);
221 }
222
223 /**
224 * Create a new field.

Callers 15

_getCellValueMethod · 0.45
getCellValueMethod · 0.45
_getCellValueMethod · 0.45
getCellValueStringMethod · 0.45
getFieldByFieldIdFunction · 0.45
KanbanViewFunction · 0.45
useAddNewCardFunction · 0.45
GroupHeaderFunction · 0.45
FieldTypeSelectFunction · 0.45
CellValueContainerFCFunction · 0.45

Calls 2

getFieldMapMethod · 0.80
findMethod · 0.45

Tested by

no test coverage detected