useRecords
Gets all the records under a given view in the datasheet. Rerendering is triggered when the value of record, view configuration, field configuration changes. Get all the records may cause lag due to a sharp increase in computation, so please use caution and test well.
Parameters
Name | Type | Description |
---|---|---|
viewId | string | undefined | The ID for the view, pass undefined to return an empty array. |
query? | IRecordQuery | query configuration parameters. |
Returns
DynamicRecord
[]
Example
import { useRecords, useActiveViewId } from '@apitable/widget-sdk';
// Show record name
function RecordsTitle() {
const viewId = useActiveViewId();
const records = useRecords(viewId);
return (<div>
{records.map(record => <p>{record.title}</p>)}
</div>);
}
▸ useRecords(datasheet
, viewId
, query?
): DynamicRecord
[]
Support for loading the corresponding datasheet data records.
Parameters
Name | Type | Description |
---|---|---|
datasheet | Datasheet | undefined | Datasheet instance, by useDatasheet get. |
viewId | string | undefined | View ID, passing in undefined returns an empty array. |
query? | IRecordQuery | query configuration parameters. |
Returns
DynamicRecord
[]
Example
import { useRecords, useViewsMeta, useDatasheet } from '@apitable/widget-sdk';
// Show the primary key of records the corresponding to the datasheetId(dstXXXXXXXX) datasheet
function RecordsTitle() {
const datasheet = useDatasheet('dstXXXXXXXX');
const viewsMeta = useViewsMeta(datasheet);
const records = useRecords(datasheet, viewsMeta[0]?.id);
return (
<div>
{records.map(record => <p>{record.title}</p>)}
</div>
);
}