useFields
Get information about all fields(columns) of currently view. Rerendering is triggered when the fields property/columns order changes.
If not viewId passed in, an empty array is returned.
Parameters
Name | Type | Description |
---|---|---|
viewId | string | undefined | The ID for view. |
query? | IFieldQuery | Optional parameter that specifies which fieldId data to query. |
Returns
Field
[]
Example
import { useFields, useActiveViewId } from '@apitable/widget-sdk';
// Show all field names
function FieldNames() {
const viewId = useActiveViewId();
const fields = useFields(viewId);
return (<div>
{fields.map(field => <p key={field.id}>{field.name}</p>)}
</div>);
}
▸ useFields(datasheet
, viewId
, query?
): Field
[]
Support for loading the corresponding datasheet data fields.
Parameters
Name | Type | Description |
---|---|---|
datasheet | Datasheet | undefined | Datasheet instance, by useDatasheet get. |
viewId | string | undefined | The ID for view. |
query? | IFieldQuery | Optional parameter that specifies which fieldId data to query. |
Returns
Field
[]
Example
import { useFields, useDatasheet } from '@apitable/widget-sdk';
// Show all field names corresponding to the datasheetId(dstXXXXXXXX) datasheet
function FieldNames() {
const datasheet = useDatasheet('dstXXXXXXXX');
const fields = useFields(datasheet, 'vieXXXXXXX');
return (<div>
{fields.map(field => <p key={field.id}>{field.name}</p>)}
</div>);
}