DataSource API

View as Markdown
When rendering the DataSource component, you can get access to the API from its (ready) output.
@Component({
  selector: 'developers',
  imports: [DataSource],
  template: `
    <infinite-data-source
      primaryKey="id"
      [data]="data"
      (ready)="onReady($event)"
    />
  `,
})
export class Developers {
  protected readonly data = data;

  protected onReady(api: DataSourceApi<DATA_TYPE>) {
    // api is accessible here
    // you may want to store it in a field of your component, to use it later
  }
}
You can also get it from the (ready) output of the InfiniteTable:
@Component({
  selector: 'developers-grid',
  imports: [DataSource, InfiniteTable],
  template: `
    <infinite-data-source primaryKey="id" [data]="data">
      <infinite-table [columns]="columns" (ready)="onReady($event)" />
    </infinite-data-source>
  `,
})
export class DevelopersGrid {
  protected readonly data = data;
  protected readonly columns = columns;

  protected onReady({
    api,
    dataSourceApi,
  }: {
    api: InfiniteTableApi<DATA_TYPE>;
    dataSourceApi: DataSourceApi<DATA_TYPE>;
  }) {
    // both api and dataSourceApi are accessible here
  }
}
For API on row/group selection, see the Selection API page.

addData

(data: DATA_TYPE) => Promise

addDataArray

(data: DATA_TYPE[]) => Promise

clearAllData

() => Promise

getDataByNodePath

(nodePath: NodePath) => DATA_TYPE | null

getDataByNodePath

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

getDataByPrimaryKey

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

getIndexByPrimaryKey

(id: any) => number

getOriginalDataArray

() => DATA_TYPE[]

getPrimaryKeyByIndex

(index: number) => any | undefined

getRowInfoArray

() => InfiniteTableRowInfo[]

getRowInfoByIndex

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

getRowInfoByNodePath

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

getRowInfoByPrimaryKey

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

insertData

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

insertDataArray

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

isRowDisabled

(primaryKey: any) => boolean

isRowDisabledAt

(rowIndex: number) => boolean

onReady

(api: DataSourceApi) => void

removeData

(data: Partial<DATA_TYPE>) => Promise

removeDataArray

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

removeDataArrayByPrimaryKeys

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

removeDataByNodePath

(nodePath: NodePath) => Promise

removeDataByPrimaryKey

(primaryKey: string | number) => Promise

replaceAllData

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

setRowEnabled

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

setRowEnabledAt

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

treeApi

TreeApi<DATA_TYPE>

updateChildrenByNodePath

(children: DATA_TYPE[] | any | (children, data) => DATA_TYPE[] | any, nodePath: NodePath) => Promise, options?

updateData

(data: Partial<DATA_TYPE>, options?) => Promise

updateDataArray

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

updateDataArrayByNodePath

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

updateDataByNodePath

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

waitForNodePath

(nodePath: NodePath, options?: { timeout?: number }) => Promise<boolean>