useField
Get information about a specified field. Rerendering is triggered when a field property changes.
If no ID is passed in, undefined is returned.
Parameters
Name | Type | Description |
---|---|---|
fieldId | string | undefined | The ID for this field. |
Returns
Field
| undefined
Example
import { useField } from '@apitable/widget-sdk';
// show field name
function FieldName() {
const field = useField('fldXXXXXXX');
return <p>{field.name}</p>
}
▸ useField(datasheet
, fieldId
): Field
| undefined
Support for loading the corresponding datasheet data field.
Parameters
Name | Type | Description |
---|---|---|
datasheet | Datasheet | undefined | Datasheet instance, by useDatasheet get. |
fieldId | string | undefined | The ID for this field |
Returns
Field
| undefined
Example
import { useField, useDatasheet } from '@apitable/widget-sdk';
// show field name corresponding to the datasheetId(dstXXXXXXXX) datasheet
function FieldName() {
const datasheet = useDatasheet('dstXXXXXXXX');
const field = useField(datasheet, 'fldXXXXXXX');
return <p>{field.name}</p>
}