AdaptableDataSourceApi
Provides imperative access to the data source.
Can be used for accessing, adding, updating and removing data.
declare class AdaptableDataSourceApi extends BaseApi
Extends
BaseApi
Methods
Method | Description |
---|---|
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.
addData<T>(data: T, options?: DataSourceCRUDParam): Promise<any>;
Parameters
Parameter | Type | Description |
---|---|---|
data | T | The object to add |
options | DataSourceCRUDParam |
Returns
Promise<any>
addDataArray
Adds an array of data at the end of the data source
addDataArray<T>(dataArray: T[], options?: DataSourceCRUDParam): Promise<any>;
Parameters
Parameter | Type | Description |
---|---|---|
dataArray | T[] | The array to add |
options | DataSourceCRUDParam | options for the update |
Returns
Promise<any>
getIndexByPrimaryKey
getIndexByPrimaryKey(primaryKey: string | number): number;
Parameters
| Parameter | Type |
| ---------- | ------- | ------- |
| primaryKey | string | number
|
Returns
number
getRowDataByPrimaryKey
Returns the data item with the specified primary key.
getRowDataByPrimaryKey(primaryKey: string): unknown;
Parameters
Parameter | Type | Description |
---|---|---|
primaryKey | string | the primary key of the data to retrieve |
Returns
unknown
getRowInfoArray
getRowInfoArray(): InfiniteTableRowInfo<unknown>[];
Returns
InfiniteTableRowInfo<unknown>[]
getRowInfoByIndex
getRowInfoByIndex(index: number): InfiniteTableRowInfo<unknown> | null;
Parameters
Parameter | Type |
---|---|
index | number |
Returns
InfiniteTableRowInfo<unknown> | null
getRowInfoByPrimaryKey
getRowInfoByPrimaryKey(id: any): InfiniteTableRowInfo<unknown> | null;
Parameters
Parameter | Type |
---|---|
id | any |
Returns
InfiniteTableRowInfo<unknown> | null
getRowsData
getRowsData(config?: GetRowsDataConfig): unknown[];
Parameters
Parameter | Type |
---|---|
config | GetRowsDataConfig |
Returns
unknown[]
getTotalRowsCount
getTotalRowsCount(): number;
Returns
number
insertData
Inserts a data object at the specified position (and relative to the given primary key).
insertData<T>(data: T, options: DataSourceInsertParam): Promise<any>;
Parameters
Parameter | Type | Description |
---|---|---|
data | T | |
options | DataSourceInsertParam | Object with position and primaryKey |
Returns
Promise<any>
insertDataArray
Inserts an array of data at the specified position (and relative to the given primary key).
insertDataArray<T>(dataArray: T[], options: DataSourceInsertParam): Promise<any>;
Parameters
Parameter | Type | Description |
---|---|---|
dataArray | T[] | The array to insert in the data source |
options | DataSourceInsertParam | Object 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.
removeData<T>(data: Partial<T>, options?: DataSourceCRUDParam): Promise<any>;
Parameters
Parameter | Type | Description |
---|---|---|
data | Partial<T> | The data object to remove |
options | DataSourceCRUDParam | options 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.
removeDataArray<T>(dataArray: Partial<T>[], options?: DataSourceCRUDParam): Promise<any>;
Parameters
Parameter | Type | Description |
---|---|---|
dataArray | Partial<T>[] | The array of data items to remove |
options | DataSourceCRUDParam | options 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.
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.
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
undoDataChange(dataChange: DataChangeInfo): void;
Parameters
Parameter | Type |
---|---|
dataChange | DataChangeInfo |
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.
updateData<T>(data: Partial<T>, options?: DataSourceCRUDParam): Promise<any>;
Parameters
Parameter | Type | Description |
---|---|---|
data | Partial<T> | The data to update |
options | DataSourceCRUDParam | options 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.
updateDataArray<T>(dataArray: Partial<T>[], options?: DataSourceCRUDParam): Promise<any>;
Parameters
Parameter | Type | Description |
---|---|---|
dataArray | Partial<T>[] | The array of data to update |
options | DataSourceCRUDParam | options for the update |
Returns
Promise<any>