DataSource API
When rendering the DataSource
component, you can get access to the API by getting it from the onReady
callback prop.
<DataSource<DATA_TYPE>
onReady={(api: DataSourceApi<DATA_TYPE>) => {
// api is accessible here
// you may want to store a reference to it in a ref or somewhere in your app state
}}
You can also get it from the InfiniteTable
onReady
callback prop:
<InfiniteTable<DATA_TYPE>
columns={[...]}
onReady={(
{api, dataSourceApi}: {
api: InfiniteTableApi<DATA_TYPE>,
dataSourceApi: DataSourceApi<DATAT_TYPE>
}) => {
// both api and dataSourceApi are accessible here
}}
/>
For API on row/group selection, see the Selection API page.
addData
Adds the specified data at the end of the data source.
addDataArray
Adds an array of data at the end of the data source
getDataByPrimaryKey
Retrieves the data object for the specified primary key.
getIndexByPrimaryKey
Retrieves the index of a row by its primary key. If the row is not found, returns -1
. See related getPrimaryKeyByIndex
getPrimaryKeyByIndex
Retrieves the primary key of a row by its current index. If the row is not found, returns undefined
. See related getIndexByPrimaryKey
getRowInfoArray
Returns the current row info array. See the type definition of the row info object.
getRowInfoByIndex
Retrieves the row info object for the row at the specified index. If none found, returns null
. See related getRowInfoByPrimaryKey
.
getRowInfoByPrimaryKey
Retrieves the row info object for the row with the specified primary key. If none found, returns null
.
insertData
Inserts the given data at the specified position relative to the given primary key.
insertDataArray
Inserts an array of data at the specified position (and relative to the given primary key).
onReady
Called only once, after the DataSource component has been mounted.
removeData
Removes the data item that matches the given data object.
removeDataArray
Removes the data items that match the given data objects.
removeDataArrayByPrimaryKeys
Removes the data items with the specified primary keys.
removeDataByPrimaryKey
Removes the data item with the specified primary key.
updateData
Updates the data item to match the given data object.
updateDataArray
Updates an array of data items to match the given data objects.