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

getDataByPrimaryKey

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

Retrieves the data object for the specified primary key.

getRowInfoArray

() => InfiniteTableRowInfo[]

Returns the current row info array.

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).

updateData

(data: Partial<DATA_TYPE>) => Promise

Updates the data item to match the given data object.

updateDataArray

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

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

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.

removeDataByPrimaryKey

(primaryKey: string | number) => Promise

Removes the data item with the specified primary key.