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

(data: DATA_TYPE) => Promise

Adds the specified data at the end of the data source.

addDataArray

(data: DATA_TYPE[]) => Promise

Adds an array of data at the end of the data source

clearAllData

() => Promise

Clears all data in the DataSource.

getDataByNodePath

(nodePath: NodePath) => DATA_TYPE | null

Retrieves the data object for the specified node path.

getDataByNodePath

(nodePath: any[]) => DATA_TYPE | null

Retrieves the data object for the node with the specified path. If the node is not found, returns null. See related getDataByIndex. See related getRowInfoByNodePath.

getDataByPrimaryKey

(primaryKey: string | number) => DATA_TYPE | null

Retrieves the data object for the specified primary key.

getIndexByPrimaryKey

(id: any) => number

Retrieves the index of a row by its primary key. If the row is not found, returns -1. See related getPrimaryKeyByIndex

getOriginalDataArray

() => DATA_TYPE[]

Returns the data array that was last loaded by the DataSource

getPrimaryKeyByIndex

(index: number) => any | undefined

Retrieves the primary key of a row by its current index. If the row is not found, returns undefined. See related getIndexByPrimaryKey

getRowInfoArray

() => InfiniteTableRowInfo[]

Returns the current row info array. See the type definition of the row info object.

getRowInfoByIndex

(index: number) => InfiniteTableRowInfo<DATA_TYPE> | null

Retrieves the row info object for the row at the specified index. If none found, returns null. See related getRowInfoByPrimaryKey.

getRowInfoByNodePath

(nodePath: any[]) => InfiniteTableRowInfo<DATA_TYPE> | null

Retrieves the row info object for the node with the specified path. If the node is not found, returns null. See related getDataByNodePath.

getRowInfoByPrimaryKey

(id: any) => InfiniteTableRowInfo<DATA_TYPE> | null

Retrieves the row info object for the row with the specified primary key. If none found, returns null.

insertData

(data: DATA_TYPE, { position, primaryKey }) => Promise

Inserts the given data at the specified position relative to the given primary key.

insertDataArray

(data: DATA_TYPE[], { position, primaryKey }) => Promise

Inserts an array of data at the specified position (and relative to the given primary key).

isRowDisabled

(primaryKey: any) => boolean

Returns true if the row with the specified primary key is disabled, false otherwise.

isRowDisabledAt

(rowIndex: number) => boolean

Returns true if the row at the specified index is disabled, false otherwise.

onReady

(api: DataSourceApi) => void

Called only once, after the DataSource component has been mounted.

removeData

(data: Partial<DATA_TYPE>) => Promise

Removes the data item that matches the given data object.

removeDataArray

(data: Partial<DATA_TYPE>[]) => Promise

Removes the data items that match the given data objects.

removeDataArrayByPrimaryKeys

(primaryKeys: (string | number)[]) => Promise

Removes the data items with the specified primary keys.

removeDataByNodePath

(nodePath: NodePath) => Promise

Removes the node specified by the specified node path.

removeDataByPrimaryKey

(primaryKey: string | number) => Promise

Removes the data item with the specified primary key.

replaceAllData

(data: DATA_TYPE[], options?: DataSourceCRUDParam) => Promise

Replaces all data in the DataSource with the provided data.

setRowEnabled

(primaryKey: any, enabled: boolean) => void

Sets the enable/disable state for the row with the specified primary key.

setRowEnabledAt

(rowIndex: number, enabled: boolean) => void

Sets the enable/disable state for the row at the specified index.

treeApi

TreeApi<DATA_TYPE>

A reference to the Tree API.

updateData

(data: Partial<DATA_TYPE>) => Promise

Updates the data item to match the given data object. For updating tree nodes by path, see the updateDataByNodePath method.

updateDataArray

(data: Partial<DATA_TYPE>[]) => Promise

Updates an array of data items to match the given data objects.

updateDataArrayByNodePath

({data, nodePath}[]) => Promise

Updates the data for the nodes specified by the node paths.

updateDataByNodePath

(data: Partial<DATA_TYPE>, nodePath: NodePath) => Promise

Updates the data for the node specified by the node path.