useViewMeta
useViewMeta
▸ useViewMeta(viewId
): IViewMeta
Beta API`, possible future changes.
Gets the metadata property of the view. Pass in a viewId, and return undefined when the viewId is illegal or does not exist. Rerendering is triggered when the metadata property changes.
Parameters
Name | Type | Description |
---|---|---|
viewId | string | undefined | Need to get the view ID of the metadata property |
Returns
Example
import { useViewMeta, useActiveViewId } from '@apitable/widget-sdk';
// Show name of the currently view.
function ViewName() {
const activeViewId = useActiveViewId();
const viewMeta = useViewMeta(activeViewId);
return <p>Current view name: {viewMeta?.name}</p>;
}
▸ useViewMeta(datasheet
, viewId
): IViewMeta
Support getting the metadata property of the corresponding datasheet view.
Parameters
Name | Type | Description |
---|---|---|
datasheet | Datasheet | undefined | Datasheet instance, by useDatasheet get. |
viewId | string | undefined | Need to get the view ID of the metadata property |
Returns
Example
import { useViewMeta, useDatasheet } from '@apitable/widget-sdk';
// Show the current view name of the corresponding datasheetId(dstXXXXXXXX) datasheet.
function ViewName() {
const datasheet = useDatasheet('dstXXXXXXXX');
const viewMeta = useViewMeta(datasheet, 'viwXXXXXXX');
return <p>Current view name: {viewMeta?.name}</p>;
}