AdaptableDataSourceApi

Provides imperative access to the data source.

Can be used for accessing, adding, updating and removing data.

TypeScript
declare class AdaptableDataSourceApi extends BaseApi
Extends

BaseApi

Methods

MethodDescription
addData(data, options)Adds the specified data at the end of the data source.
addDataArray(dataArray, options)Adds an array of data at the end of the data source
getIndexByPrimaryKey(primaryKey)
getRowDataByPrimaryKey(primaryKey)Returns the data item with the specified primary key.
getRowInfoArray()
getRowInfoByIndex(index)
getRowInfoByPrimaryKey(id)
getRowsData(config)
getTotalRowsCount()
insertData(data, options)Inserts a data object at the specified position (and relative to the given primary key).
insertDataArray(dataArray, options)Inserts an array of data at the specified position (and relative to the given primary key).
removeData(data, options)Removes the data item that matches the given data object.
removeDataArray(dataArray, options)Removes the data items that match the given data objects.
removeDataArrayByPrimaryKeys(primaryKeys, options)Removes the data items with the specified primary keys.
removeDataByPrimaryKey(primaryKey, options)Removes the data item with the specified primary key.
undoDataChange(dataChange)
updateData(data, options)Updates the data item to match the given data object. The data object must have a primary key that matches the primary key of the data item that you want to update. Besides the primary key, it can contain any number of properties that you want to update.
updateDataArray(dataArray, options)Updates an array of data items to match the given data objects.

Method Details

addData

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

TypeScript
addData<T>(data: T, options?: DataSourceCRUDParam): Promise<any>;
Parameters
ParameterTypeDescription
dataTThe object to add
optionsDataSourceCRUDParam
Returns

Promise<any>

addDataArray

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

TypeScript
addDataArray<T>(dataArray: T[], options?: DataSourceCRUDParam): Promise<any>;
Parameters
ParameterTypeDescription
dataArrayT[]The array to add
optionsDataSourceCRUDParamoptions for the update
Returns

Promise<any>

getIndexByPrimaryKey

TypeScript
getIndexByPrimaryKey(primaryKey: string | number): number;
Parameters

| Parameter | Type | | ---------- | ------- | ------- | | primaryKey | string | number |

Returns

number

getRowDataByPrimaryKey

Returns the data item with the specified primary key.

TypeScript
getRowDataByPrimaryKey(primaryKey: string): unknown;
Parameters
ParameterTypeDescription
primaryKeystringthe primary key of the data to retrieve
Returns

unknown

getRowInfoArray

TypeScript
getRowInfoArray(): InfiniteTableRowInfo<unknown>[];
Returns

InfiniteTableRowInfo<unknown>[]

getRowInfoByIndex

TypeScript
getRowInfoByIndex(index: number): InfiniteTableRowInfo<unknown> | null;
Parameters
ParameterType
indexnumber
Returns

InfiniteTableRowInfo<unknown> | null

getRowInfoByPrimaryKey

TypeScript
getRowInfoByPrimaryKey(id: any): InfiniteTableRowInfo<unknown> | null;
Parameters
ParameterType
idany
Returns

InfiniteTableRowInfo<unknown> | null

getRowsData

TypeScript
getRowsData(config?: GetRowsDataConfig): unknown[];
Parameters
ParameterType
configGetRowsDataConfig
Returns

unknown[]

getTotalRowsCount

TypeScript
getTotalRowsCount(): number;
Returns

number

insertData

Inserts a data object at the specified position (and relative to the given primary key).

TypeScript
insertData<T>(data: T, options: DataSourceInsertParam): Promise<any>;
Parameters
ParameterTypeDescription
dataT
optionsDataSourceInsertParamObject with position and primaryKey
Returns

Promise<any>

insertDataArray

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

TypeScript
insertDataArray<T>(dataArray: T[], options: DataSourceInsertParam): Promise<any>;
Parameters
ParameterTypeDescription
dataArrayT[]The array to insert in the data source
optionsDataSourceInsertParamObject with position and primaryKey
Returns

Promise<any>

removeData

Removes the data item that matches the given data object.

The data object must at least have a primary key that matches the primary key of the data item that you want to remove. All the other properties are ignored.

TypeScript
removeData<T>(data: Partial<T>, options?: DataSourceCRUDParam): Promise<any>;
Parameters
ParameterTypeDescription
dataPartial<T>The data object to remove
optionsDataSourceCRUDParamoptions for the update. if options.flush is true, the data source will be flushed/updated immediately.
Returns

Promise<any>

removeDataArray

Removes the data items that match the given data objects.

TypeScript
removeDataArray<T>(dataArray: Partial<T>[], options?: DataSourceCRUDParam): Promise<any>;
Parameters
ParameterTypeDescription
dataArrayPartial<T>[]The array of data items to remove
optionsDataSourceCRUDParamoptions for the update. if options.flush is true, the data source will be flushed/updated immediately.
Returns

Promise<any>

removeDataArrayByPrimaryKeys

Removes the data items with the specified primary keys.

TypeScript
removeDataArrayByPrimaryKeys(primaryKeys: (string | number)[], options?: DataSourceCRUDParam): Promise<any>;
Parameters

| Parameter | Type | Description | | ----------- | --------------------- | -------------------------------------------------------------------------------------------------------- | ---------------------------------- | | primaryKeys | (string | number)[] | An array of primary keys to remove | | options | DataSourceCRUDParam | options for the update. if options.flush is true, the data source will be flushed/updated immediately. |

Returns

Promise<any>

removeDataByPrimaryKey

Removes the data item with the specified primary key.

TypeScript
removeDataByPrimaryKey(primaryKey: string | number, options?: DataSourceCRUDParam): Promise<any>;
Parameters

| Parameter | Type | Description | | ---------- | --------------------- | -------------------------------------------------------------------------------------------------------- | ------------------------------------- | | primaryKey | string | number | The primary key of the item to remove | | options | DataSourceCRUDParam | options for the update. if options.flush is true, the data source will be flushed/updated immediately. |

Returns

Promise<any>

undoDataChange

TypeScript
undoDataChange(dataChange: DataChangeInfo): void;
Parameters
ParameterType
dataChangeDataChangeInfo
Returns

void

updateData

Updates the data item to match the given data object. The data object must have a primary key that matches the primary key of the data item that you want to update. Besides the primary key, it can contain any number of properties that you want to update.

TypeScript
updateData<T>(data: Partial<T>, options?: DataSourceCRUDParam): Promise<any>;
Parameters
ParameterTypeDescription
dataPartial<T>The data to update
optionsDataSourceCRUDParamoptions for the update
Returns

Promise<any>

updateDataArray

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

Each of the the data objects must have a primary key that matches the primary key of the data item that you want to update. Besides the primary key, it can contain any number of properties that you want to update.

TypeScript
updateDataArray<T>(dataArray: Partial<T>[], options?: DataSourceCRUDParam): Promise<any>;
Parameters
ParameterTypeDescription
dataArrayPartial<T>[]The array of data to update
optionsDataSourceCRUDParamoptions for the update
Returns

Promise<any>