Skip to main content

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

NameTypeDescription
viewIdstring | undefinedNeed to get the view ID of the metadata property

Returns

IViewMeta

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

NameTypeDescription
datasheetDatasheet | undefinedDatasheet instance, by useDatasheet get.
viewIdstring | undefinedNeed to get the view ID of the metadata property

Returns

IViewMeta

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>;
}