# Infinite Table Props

> Infinite Table Props Reference page with complete examples

Canonical page: https://infinite-table.com/angular/docs/reference/infinite-table-props

In the API Reference below we'll use **`DATA_TYPE`** to refer to the TypeScript type that represents the data the component is bound to.

The props are listed with the names you use in an Angular template: `[(columnOrder)]` is a model (bind it two-way to a signal), `(columnOrderChange)` and `(cellClick)` are outputs, `[onKeyDown]` is a function input. The other inputs keep their names. The examples are written for Angular.

### debugId (`string`)

> The unique id to identify this InfiniteTable instance in devtools

If you have [Infinite Table DevTools extension](https://chromewebstore.google.com/detail/infinite-table-devtools-e/jpipjljbfffijmgiecljadbogfegejfa) installed, the current `<InfiniteTable />` instance will be picked up by the devtools with this specific name.

See [our blogpost on the devtools extension](https://infinite-table.com/blog/2025/05/12/the-first-devtools-for-a-datagrid.md) for more details.

### repeatWrappedGroupRows (`boolean|(rowInfo: InfiniteTableRowInfo<DATA_TYPE>) => boolean`)

> When enabled, and [`wrapRowsHorizontally`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#wrapRowsHorizontally) is also enabled, if there is [grouping configured](https://infinite-table.com/angular/docs/reference/datasource-props/index.md#groupBy) or if you're using tree data, the group/tree rows will be repeated at the top of each column set if the group/parent starts in the previous column set.

See related [`wrapRowsHorizontally`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#wrapRowsHorizontally).

**Example: Horizontal Layout with repeated wrapped group rows**

```ts
import { Component, signal } from '@angular/core';

import { DataSource, InfiniteTable } from '@infinite-table/infinite-angular';
import type {
  DataSourceData,
  DataSourcePropGroupBy,
  InfiniteTablePropColumns,
} from '@infinite-table/infinite-angular';

type Developer = {
  id: number;
  firstName: string;
  lastName: string;
  country: string;
  city: string;
  currency: string;
  preferredLanguage: string;
  stack: string;
  canDesign: 'yes' | 'no';
  hobby: string;
  salary: number;
  age: number;
};

const dataSource: DataSourceData<Developer> = () => {
  return fetch(
    'https://infinite-table.com/.netlify/functions/json-server' +
      `/developers1k-sql?`,
  )
    .then((r) => r.json())
    .then((data: Developer[]) => data);
};

const columns: InfiniteTablePropColumns<Developer> = {
  id: { field: 'id', header: 'ID', defaultWidth: 50 },

  country: { field: 'country', header: 'Country' },
  city: { field: 'city', header: 'City' },
  firstName: { field: 'firstName', header: 'First Name' },
  separator: {
    valueGetter: () => null,
    resizable: false,
    defaultWidth: 10,
    style: {
      background: 'var(--infinite-background)',
    },
  },
};

const defaultGroupBy: DataSourcePropGroupBy<Developer> = [
  {
    field: 'country',
  },
  {
    field: 'city',
  },
];

@Component({
  selector: 'demo-root',
  imports: [DataSource, InfiniteTable],
  template: `
    <div style="color: var(--infinite-cell-color); margin-bottom: 10px">
      <button (click)="repeatWrappedGroupRows.set(!repeatWrappedGroupRows())">
        {{ repeatWrappedGroupRows() ? 'Disable' : 'Enable' }} Repeat Wrapped
        Group Rows
      </button>
    </div>
    <infinite-data-source
      primaryKey="id"
      [data]="dataSource"
      [defaultGroupBy]="defaultGroupBy"
    >
      <infinite-table
        debugId="horizontal-layout-repeat-wrapped-groups-example"
        [wrapRowsHorizontally]="true"
        [repeatWrappedGroupRows]="repeatWrappedGroupRows()"
        [columns]="columns"
        [columnDefaultWidth]="100"
        [columnDefaultSortable]="false"
      />
    </infinite-data-source>
  `,
})
export default class App {
  protected readonly dataSource = dataSource;
  protected readonly columns = columns;
  protected readonly defaultGroupBy = defaultGroupBy;

  protected readonly repeatWrappedGroupRows = signal(false);
}
```

In this example, parent nodes are repeated conditionally: only top-level parent nodes are repeated when wrapping happens.

**Example: Tree with horizontal Layout and repeated wrapped tree rows**

```ts
import { Component } from '@angular/core';

import { TreeDataSource, TreeGrid } from '@infinite-table/infinite-angular';
import type {
  InfiniteTableColumn,
  InfiniteTableRowInfo,
} from '@infinite-table/infinite-angular';

type FileSystemNode = {
  id: string;
  name: string;
  type: 'folder' | 'file';
  extension?: string;
  sizeInKB: number;
  children?: FileSystemNode[];
};

const columns: Record<string, InfiniteTableColumn<FileSystemNode>> = {
  name: { renderTreeIcon: true, field: 'name', header: 'Name' },
  type: { field: 'type', header: 'Type' },
  extension: { field: 'extension', header: 'Extension' },
  size: { field: 'sizeInKB', type: 'number', header: 'Size (KB)' },
};

// repeat only the top-level tree nodes at the top of each wrapped column set
const repeatWrappedGroupRows = (
  rowInfo: InfiniteTableRowInfo<FileSystemNode>,
) => {
  if (!rowInfo.isTreeNode) {
    return false;
  }
  return rowInfo.treeNesting === 0;
};

const dataSource = () => {
  const nodes: FileSystemNode[] = [
    {
      id: '1',
      name: 'Documents',
      sizeInKB: 1200,
      type: 'folder',
      children: [
        {
          id: '10',
          name: 'Private',
          sizeInKB: 100,
          type: 'folder',
          children: [
            {
              id: '100',
              name: 'Report.docx',
              sizeInKB: 210,
              type: 'file',
              extension: 'docx',
            },
            {
              id: '101',
              name: 'Vacation.docx',
              sizeInKB: 120,
              type: 'file',
              extension: 'docx',
            },
            {
              id: '102',
              name: 'CV.pdf',
              sizeInKB: 108,
              type: 'file',
              extension: 'pdf',
            },
          ],
        },
      ],
    },
    {
      id: '2',
      name: 'Desktop',
      sizeInKB: 1000,
      type: 'folder',
      children: [
        {
          id: '20',
          name: 'unknown.txt',
          sizeInKB: 100,
          type: 'file',
          extension: 'txt',
        },
      ],
    },
    {
      id: '3',
      name: 'Media',
      sizeInKB: 1000,
      type: 'folder',
      children: [
        {
          id: '30',
          name: 'Music',
          sizeInKB: 0,
          type: 'folder',
          children: [
            {
              id: '300',
              name: 'empty.mp3',
              sizeInKB: 0,
              type: 'file',
            },
            {
              id: '301',
              name: 'Hawaii Song.mp3',
              sizeInKB: 108,
              type: 'file',
              extension: 'mp3',
            },
            {
              id: '302',
              name: 'Independence Day Song.mp3',
              sizeInKB: 108,
              type: 'file',
              extension: 'mp3',
            },
            {
              id: '303',
              name: 'Pop Song.mp3',
              sizeInKB: 108,
              type: 'file',
              extension: 'mp3',
            },
          ],
        },
        {
          id: '31',
          name: 'Videos',
          sizeInKB: 5400,
          type: 'folder',
          children: [
            {
              id: '310',
              name: 'Vacation.mp4',
              sizeInKB: 108,
              type: 'file',
              extension: 'mp4',
            },
            {
              id: '311',
              name: 'Honolulu.mp4',
              sizeInKB: 108,
              type: 'file',
              extension: 'mp4',
            },
            {
              id: '312',
              name: 'New York.mp4',
              sizeInKB: 108,
              type: 'file',
              extension: 'mp4',
            },
          ],
        },
      ],
    },
  ];
  return Promise.resolve(nodes);
};

@Component({
  selector: 'demo-root',
  imports: [TreeDataSource, TreeGrid],
  template: `
    <infinite-tree-data-source
      nodesKey="children"
      primaryKey="id"
      [data]="dataSource"
    >
      <infinite-tree-grid
        [columns]="columns"
        wrapRowsHorizontally
        [repeatWrappedGroupRows]="repeatWrappedGroupRows"
      />
    </infinite-tree-data-source>
  `,
})
export default class App {
  protected readonly dataSource = dataSource;
  protected readonly columns = columns;
  protected readonly repeatWrappedGroupRows = repeatWrappedGroupRows;
}
```

### wrapRowsHorizontally (`boolean`)

> Whether to wrap rows horizontally or not. Horizontal Layout is a very different approach to the normal grid layout and only useful in very advanced scenarios.

When this is set to `true`, rows will be wrapped horizontally to fit the container.

When horizontal layout is enabled in combination with grouping, you can also use the [`repeatWrappedGroupRows`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#repeatWrappedGroupRows) property to repeat the group rows at the top of each column set - if the group starts in the previous column set.

When horizontal layout is enabled, rows will wrap and the existing columns will be repeated for each row-wrapping section - we will call them  column sets.

So for example when the DataGrid is configured with 3 columns and the DataSource has 25 rows, but only 10 rows fit in the vertical viewport, you will end up with 3 column-sets: the first with 10 rows, the second with the next 10 rows, and the third with the remaining 5 rows. The same columns are repeated for each column-set.

**Example: Horizontal Layout example**

```ts
import { Component, signal } from '@angular/core';

import { DataSource, InfiniteTable } from '@infinite-table/infinite-angular';
import type {
  DataSourceData,
  InfiniteTablePropColumns,
} from '@infinite-table/infinite-angular';

type Developer = {
  id: number;
  firstName: string;
  lastName: string;
  country: string;
  city: string;
  currency: string;
  preferredLanguage: string;
  stack: string;
  canDesign: 'yes' | 'no';
  hobby: string;
  salary: number;
  age: number;
};

const dataSource: DataSourceData<Developer> = () => {
  return fetch(
    'https://infinite-table.com/.netlify/functions/json-server' +
      `/developers1k-sql?`,
  )
    .then((r) => r.json())
    .then((data: Developer[]) => data);
};

const columns: InfiniteTablePropColumns<Developer> = {
  id: { field: 'id', header: 'ID', defaultWidth: 50 },
  firstName: { field: 'firstName', header: 'First Name' },
  age: { field: 'age', header: 'Age' },
};

@Component({
  selector: 'demo-root',
  imports: [DataSource, InfiniteTable],
  template: `
    <div style="color: var(--infinite-cell-color); margin-bottom: 10px">
      <button (click)="wrapRowsHorizontally.set(!wrapRowsHorizontally())">
        {{ wrapRowsHorizontally() ? 'Disable' : 'Enable' }} Horizontal Layout
      </button>
    </div>
    <infinite-data-source primaryKey="id" [data]="dataSource">
      <infinite-table
        debugId="horizontal-layout-example"
        [wrapRowsHorizontally]="wrapRowsHorizontally()"
        [columns]="columns"
        [columnDefaultWidth]="100"
        [columnDefaultSortable]="false"
      />
    </infinite-data-source>
  `,
})
export default class App {
  protected readonly dataSource = dataSource;
  protected readonly columns = columns;

  protected readonly wrapRowsHorizontally = signal(false);
}
```

In the column rendering functions (both for header and cell rendering), you will have access to the `horizontalLayoutPageIndex` property. This is the index of the current horizontal layout page (the current column-set). `horizontalLayoutPageIndex` can either be `null`, when horizontal layout is disabled, or a number >= 0, when horizontal layout is enabled.

When using horizontal layout, columns can't be configured to have a flexible width. So don't specify [`columns.defaultFlex`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#columns.defaultFlex) for any column when horizontal layout is enabled.

**Example: Horizontal Layout example with column set index in header**

```ts
import { Component, signal } from '@angular/core';

import { DataSource, InfiniteTable } from '@infinite-table/infinite-angular';
import type {
  DataSourceData,
  InfiniteTableColumn,
  InfiniteTablePropColumns,
} from '@infinite-table/infinite-angular';

type Developer = {
  id: number;
  firstName: string;
  lastName: string;
  country: string;
  city: string;
  currency: string;
  preferredLanguage: string;
  stack: string;
  canDesign: 'yes' | 'no';
  hobby: string;
  salary: number;
  age: number;
};

const dataSource: DataSourceData<Developer> = () => {
  return fetch(
    'https://infinite-table.com/.netlify/functions/json-server' +
      `/developers1k-sql?`,
  )
    .then((r) => r.json())
    .then((data: Developer[]) => data);
};

const getColumnHeaderFor = (
  label: string,
): InfiniteTableColumn<Developer>['header'] => {
  return ({
    horizontalLayoutPageIndex,
  }: {
    horizontalLayoutPageIndex: number | null;
  }) => {
    return `${label}${
      horizontalLayoutPageIndex != null
        ? `(${horizontalLayoutPageIndex + 1})`
        : ''
    }`;
  };
};
const columns: InfiniteTablePropColumns<Developer> = {
  id: {
    field: 'id',
    defaultWidth: 80,
    header: getColumnHeaderFor('ID'),
  },
  firstName: { field: 'firstName', header: getColumnHeaderFor('Name') },
  age: { field: 'age', header: getColumnHeaderFor('Age') },
};

@Component({
  selector: 'demo-root',
  imports: [DataSource, InfiniteTable],
  template: `
    <div style="color: var(--infinite-cell-color); margin-bottom: 10px">
      <button (click)="wrapRowsHorizontally.set(!wrapRowsHorizontally())">
        {{ wrapRowsHorizontally() ? 'Disable' : 'Enable' }} Horizontal Layout
      </button>
    </div>
    <infinite-data-source primaryKey="id" [data]="dataSource">
      <infinite-table
        debugId="horizontal-layout-with-column-set-index-in-header-example"
        [wrapRowsHorizontally]="wrapRowsHorizontally()"
        [columns]="columns"
        [columnDefaultWidth]="100"
        [columnDefaultSortable]="false"
      />
    </infinite-data-source>
  `,
})
export default class App {
  protected readonly dataSource = dataSource;
  protected readonly columns = columns;

  protected readonly wrapRowsHorizontally = signal(true);
}
```

### components.RowDetail

> Component to use for rendering the row details section in the master-detail DataGrid. When specified, it makes InfiniteTable be a [master-detail DataGrid](https://infinite-table.com/angular/docs/learn/master-detail/overview.md). For configuring the height of row details, see [`rowDetailHeight`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#rowDetailHeight)

See related [`rowDetailRenderer`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#rowDetailRenderer).

This example shows a master DataGrid with cities & countries.

The details for each city shows a DataGrid with developers in that city.

**Example: Basic master detail DataGrid example**

```ts
import { Component } from '@angular/core';

import {
  DataSource,
  InfiniteTable,
  injectMasterRowInfo,
} from '@infinite-table/infinite-angular';
import type {
  DataSourceData,
  InfiniteTablePropColumns,
} from '@infinite-table/infinite-angular';

type Developer = {
  id: number;
  firstName: string;
  lastName: string;

  city: string;
  currency: string;
  country: string;
  preferredLanguage: string;
  stack: string;
  canDesign: 'yes' | 'no';

  salary: number;
};

type City = {
  id: number;
  name: string;
  country: string;
};

const masterColumns: InfiniteTablePropColumns<City> = {
  id: {
    field: 'id',
    header: 'ID',
    defaultWidth: 70,
    renderRowDetailIcon: true,
  },
  country: { field: 'country', header: 'Country' },
  city: { field: 'name', header: 'City', defaultFlex: 1 },
};

const detailColumns: InfiniteTablePropColumns<Developer> = {
  firstName: {
    field: 'firstName',
    header: 'First Name',
  },
  salary: {
    field: 'salary',
    type: 'number',
  },

  stack: { field: 'stack' },
  currency: { field: 'currency' },
  city: { field: 'city' },
};

const domProps = {
  style: {
    height: '100%',
  },
};
const shouldReloadData = {
  sortInfo: true,
  filterValue: true,
};

// fetch an array of cities from the server
const citiesDataSource: DataSourceData<City> = () => {
  const cityNames = new Set<string>();
  const result: City[] = [];
  return fetch(process.env.NEXT_PUBLIC_BASE_URL + `/developers1k-sql`)
    .then((response) => response.json())
    .then((response) => {
      response.data.forEach((data: Developer) => {
        if (cityNames.has(data.city)) {
          return;
        }
        cityNames.add(data.city);
        result.push({
          name: data.city,
          country: data.country,
          id: result.length,
        });
      });

      return result;
    });
};

const detailDataSource: DataSourceData<Developer> = ({
  filterValue,
  sortInfo,
  masterRowInfo,
}) => {
  if (sortInfo && !Array.isArray(sortInfo)) {
    sortInfo = [sortInfo];
  }

  if (!filterValue) {
    filterValue = [];
  }
  if (masterRowInfo) {
    // filter by master country and city
    filterValue = [
      {
        field: 'city',
        filter: {
          operator: 'eq',
          type: 'string',
          value: masterRowInfo.data.name,
        },
      },
      {
        field: 'country',
        filter: {
          operator: 'eq',
          type: 'string',
          value: masterRowInfo.data.country,
        },
      },
      ...filterValue,
    ];
  }
  const args = [
    sortInfo
      ? 'sortInfo=' +
        JSON.stringify(
          sortInfo.map((s) => ({
            field: s.field,
            dir: s.dir,
          })),
        )
      : null,

    filterValue
      ? 'filterBy=' +
        JSON.stringify(
          filterValue.map(({ field, filter }) => {
            return {
              field: field,
              operator: filter.operator,
              value:
                filter.type === 'number' ? Number(filter.value) : filter.value,
            };
          }),
        )
      : null,
  ]
    .filter(Boolean)
    .join('&');

  return fetch(process.env.NEXT_PUBLIC_BASE_URL + `/developers1k-sql?` + args)
    .then((r) => r.json())
    .then((data: Developer[]) => data);
};


@Component({
  selector: 'row-detail',
  imports: [DataSource, InfiniteTable],
  // laid out by the row detail element, as the grid would be
  host: { style: 'display: contents' },
  template: `
    <infinite-data-source
      [data]="detailDataSource"
      primaryKey="id"
      [shouldReloadData]="shouldReloadData"
    >
      <infinite-table
        debugId="master-detail-component-example"
        [columnDefaultWidth]="150"
        [columnMinWidth]="50"
        [columns]="detailColumns"
      />
    </infinite-data-source>
  `,
})
class RowDetail {
  private readonly rowInfo = injectMasterRowInfo<City>();

  protected readonly detailDataSource = detailDataSource;
  protected readonly detailColumns = detailColumns;
  protected readonly shouldReloadData = shouldReloadData;

  constructor() {
    console.log('rendering detail for master row', this.rowInfo()!.id);
  }
}

const components = {
  RowDetail,
};

@Component({
  selector: 'demo-root',
  imports: [DataSource, InfiniteTable],
  template: `
    <infinite-data-source
      [data]="citiesDataSource"
      primaryKey="id"
      [defaultSortInfo]="[
        {
          field: 'country',
          dir: 1,
        },
        {
          field: 'name',
          dir: 1,
        },
      ]"
    >
      <infinite-table
        debugId="master-detail-component-example-2"
        [domProps]="domProps"
        [columnDefaultWidth]="150"
        [columnMinWidth]="50"
        [columns]="masterColumns"
        [components]="components"
      />
    </infinite-data-source>
  `,
})
export default class App {
  protected readonly citiesDataSource = citiesDataSource;
  protected readonly masterColumns = masterColumns;
  protected readonly domProps = domProps;
  protected readonly components = components;
}
```

### scrollStopDelay (`number`)

> The delay in milliseconds that the DataGrid waits until it considers scrolling to be stopped. Also used when lazy loading is to fetch the next batch of data.

This also determines when the [`(scrollStop)`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#onScrollStop) callback prop is called.

**Example: Scroll stop delay for lazy loading**

```ts
import { Component } from '@angular/core';

import { DataSource, InfiniteTable } from '@infinite-table/infinite-angular';
import type {
  DataSourceData,
  InfiniteTablePropColumns,
} from '@infinite-table/infinite-angular';

type Developer = {
  id: number;
  firstName: string;
  lastName: string;
  country: string;
  city: string;
  currency: string;
  preferredLanguage: string;
  stack: string;
  canDesign: 'yes' | 'no';
  hobby: string;
  salary: number;
  age: number;
};

const columns: InfiniteTablePropColumns<Developer> = {
  id: { field: 'id', header: 'ID', defaultWidth: 100 },
  salary: { field: 'salary', header: 'Salary' },
  age: { field: 'age', header: 'Age' },
  firstName: { field: 'firstName', header: 'First Name' },
  preferredLanguage: {
    field: 'preferredLanguage',
    header: 'Preferred Language',
  },
  lastName: { field: 'lastName', header: 'Last Name' },
  country: { field: 'country', header: 'Country' },
  city: { field: 'city', header: 'City' },
  currency: { field: 'currency', header: 'Currency' },
  stack: { field: 'stack', header: 'Stack' },
  canDesign: { field: 'canDesign', header: 'Can Design' },
  hobby: { field: 'hobby', header: 'Hobby' },
};

const lazyLoad = { batchSize: 40 };

const dataSource: DataSourceData<Developer> = ({
  pivotBy,
  aggregationReducers,
  groupBy,

  lazyLoadStartIndex,
  lazyLoadBatchSize,
  groupKeys = [],
  sortInfo,
}) => {
  if (sortInfo && !Array.isArray(sortInfo)) {
    sortInfo = [sortInfo];
  }
  const startLimit: string[] = [];
  if (lazyLoadBatchSize && lazyLoadBatchSize > 0) {
    const start = lazyLoadStartIndex || 0;
    startLimit.push(`start=${start}`);
    startLimit.push(`limit=${lazyLoadBatchSize}`);
  }
  const args = [
    ...startLimit,
    pivotBy
      ? 'pivotBy=' + JSON.stringify(pivotBy.map((p) => ({ field: p.field })))
      : null,
    `groupKeys=${JSON.stringify(groupKeys)}`,
    groupBy
      ? 'groupBy=' + JSON.stringify(groupBy.map((p) => ({ field: p.field })))
      : null,
    sortInfo
      ? 'sortInfo=' +
        JSON.stringify(
          sortInfo.map((s) => ({
            field: s.field,
            dir: s.dir,
          })),
        )
      : null,
    aggregationReducers
      ? 'reducers=' +
        JSON.stringify(
          Object.keys(aggregationReducers).map((key) => ({
            field: aggregationReducers[key].field,
            id: key,
            name: aggregationReducers[key].reducer,
          })),
        )
      : null,
  ]
    .filter(Boolean)
    .join('&');
  return fetch(
    process.env.NEXT_PUBLIC_BASE_URL + `/developers10k-sql?` + args,
  ).then((r) => r.json());
};

@Component({
  selector: 'demo-root',
  imports: [DataSource, InfiniteTable],
  template: `
    <infinite-data-source
      [data]="dataSource"
      primaryKey="id"
      [lazyLoad]="lazyLoad"
    >
      <infinite-table
        debugId="scrollStopDelay-lazy-load-example"
        [columns]="columns"
        [columnDefaultWidth]="130"
        [scrollStopDelay]="50"
      />
    </infinite-data-source>
  `,
})
export default class App {
  protected readonly dataSource = dataSource;
  protected readonly columns = columns;
  protected readonly lazyLoad = lazyLoad;
}
```

### headerOptions (`{alwaysReserveSpaceForSortIcon: boolean}`)

> Various header configurations for the DataGrid.

For now, it has the following properties:

 - [`headerOptions.alwaysReserveSpaceForSortIcon`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#headerOptions.alwaysReserveSpaceForSortIcon)

```ts
import { Component, computed, signal } from '@angular/core';

import {
  DataSource,
  InfiniteCheckBox,
  InfiniteTable,
} from '@infinite-table/infinite-angular';
import type { InfiniteTableColumn } from '@infinite-table/infinite-angular';

export const columns: Record<string, InfiniteTableColumn<Employee>> = {
  firstName: {
    field: 'firstName',
    header: 'First Name',
  },
  country: {
    field: 'country',
    header: 'Country',
  },
  city: {
    field: 'city',
    header: 'Location: City',
  },
  salary: {
    field: 'salary',
    type: 'number',
    header: 'Salary',
  },
};

@Component({
  selector: 'demo-root',
  imports: [DataSource, InfiniteTable, InfiniteCheckBox],
  template: `
    <div style="color: var(--infinite-cell-color); padding: 10px">
      <input
        infiniteCheckBox
        [checked]="reserveSpaceForSortIcon()"
        (checkedChange)="reserveSpaceForSortIcon.set(!reserveSpaceForSortIcon())"
      />Reserve space for sort icon
    </div>
    <infinite-data-source [data]="dataSource" primaryKey="id">
      <infinite-table
        debugId="sortIcon-reserve-space-example"
        [headerOptions]="headerOptions()"
        [columns]="columns"
        [columnDefaultWidth]="100"
        [columnMinWidth]="30"
      />
    </infinite-data-source>
  `,
})
export default class App {
  protected readonly dataSource = dataSource;
  protected readonly columns = columns;

  protected readonly reserveSpaceForSortIcon = signal(true);

  protected readonly headerOptions = computed(() => ({
    alwaysReserveSpaceForSortIcon: this.reserveSpaceForSortIcon(),
  }));
}

const dataSource = () => {
  return fetch(process.env.NEXT_PUBLIC_BASE_URL + '/employees100')
    .then((r) => r.json())
    .then((data: Employee[]) => data);
};

export type Employee = {
  id: number;
  companyName: string;
  companySize: string;
  firstName: string;
  lastName: string;
  country: string;
  countryCode: string;
  city: string;
  streetName: string;
  streetNo: string;
  department: string;
  team: string;
  salary: number;
  age: number;
  email: string;
};
```

### headerOptions.alwaysReserveSpaceForSortIcon (`boolean`)

> Whether to reserve space in the column header for the sort icon or not.

When this is set to `true`, the space for the sort icon is always reserved, even if the column is not currently sorted.

```ts
import { Component, computed, signal } from '@angular/core';

import {
  DataSource,
  InfiniteCheckBox,
  InfiniteTable,
} from '@infinite-table/infinite-angular';
import type { InfiniteTableColumn } from '@infinite-table/infinite-angular';

export const columns: Record<string, InfiniteTableColumn<Employee>> = {
  firstName: {
    field: 'firstName',
    header: 'First Name',
  },
  country: {
    field: 'country',
    header: 'Country',
  },
  city: {
    field: 'city',
    header: 'Location: City',
  },
  salary: {
    field: 'salary',
    type: 'number',
    header: 'Salary',
  },
};

@Component({
  selector: 'demo-root',
  imports: [DataSource, InfiniteTable, InfiniteCheckBox],
  template: `
    <div style="color: var(--infinite-cell-color); padding: 10px">
      <input
        infiniteCheckBox
        [checked]="reserveSpaceForSortIcon()"
        (checkedChange)="reserveSpaceForSortIcon.set(!reserveSpaceForSortIcon())"
      />Reserve space for sort icon
    </div>
    <infinite-data-source [data]="dataSource" primaryKey="id">
      <infinite-table
        debugId="sortIcon-reserve-space-example"
        [headerOptions]="headerOptions()"
        [columns]="columns"
        [columnDefaultWidth]="100"
        [columnMinWidth]="30"
      />
    </infinite-data-source>
  `,
})
export default class App {
  protected readonly dataSource = dataSource;
  protected readonly columns = columns;

  protected readonly reserveSpaceForSortIcon = signal(true);

  protected readonly headerOptions = computed(() => ({
    alwaysReserveSpaceForSortIcon: this.reserveSpaceForSortIcon(),
  }));
}

const dataSource = () => {
  return fetch(process.env.NEXT_PUBLIC_BASE_URL + '/employees100')
    .then((r) => r.json())
    .then((data: Employee[]) => data);
};

export type Employee = {
  id: number;
  companyName: string;
  companySize: string;
  firstName: string;
  lastName: string;
  country: string;
  countryCode: string;
  city: string;
  streetName: string;
  streetNo: string;
  department: string;
  team: string;
  salary: number;
  age: number;
  email: string;
};
```

### rowDetailRenderer (`(rowInfo: InfiniteTableRowInfo<DATA_TYPE>) => ReactNode`)

> When specified, it makes InfiniteTable be a [master-detail DataGrid](https://infinite-table.com/angular/docs/learn/master-detail/overview.md). For configuring the height of row details, see [`rowDetailHeight`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#rowDetailHeight). See related [`components.RowDetail`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#components.RowDetail).

It's an alternative to using [`components.RowDetail`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#components.RowDetail).

This function is called with the [rowInfo](https://infinite-table.com/docs/reference/type-definitions/index.md#InfiniteTableRowInfo) the user expands to see details for.

Using this function, you can render another DataGrid or any other custom content.

Make sure you have a column with the `renderRowDetailIcon: true` flag set. [`columns.renderRowDetailIcon`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#columns.renderRowDetailIcon) on a column makes the column display the row details expand icon.

Without this flag, no column will have the expand icon, and the master-detail functionality will not work.

To configure the height of the row details section, use the [`rowDetailHeight`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#rowDetailHeight) prop.

For rendering some row details as already expanded, see [`defaultRowDetailState`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#defaultRowDetailState).

This example shows a master DataGrid with cities & countries.

The details for each city shows a DataGrid with developers in that city.

**Example: Basic master detail DataGrid example**

```ts
import { Component, TemplateRef, viewChild } from '@angular/core';

import { DataSource, InfiniteTable } from '@infinite-table/infinite-angular';
import type {
  DataSourceData,
  InfiniteTablePropColumns,
  InfiniteTableRowInfo,
} from '@infinite-table/infinite-angular';

type Developer = {
  id: number;
  firstName: string;
  lastName: string;

  city: string;
  currency: string;
  country: string;
  preferredLanguage: string;
  stack: string;
  canDesign: 'yes' | 'no';

  salary: number;
};

type City = {
  id: number;
  name: string;
  country: string;
};

const masterColumns: InfiniteTablePropColumns<City> = {
  id: {
    field: 'id',
    header: 'ID',
    defaultWidth: 70,
    renderRowDetailIcon: true,
  },
  country: { field: 'country', header: 'Country' },
  city: { field: 'name', header: 'City', defaultFlex: 1 },
};

const detailColumns: InfiniteTablePropColumns<Developer> = {
  firstName: {
    field: 'firstName',
    header: 'First Name',
  },
  salary: {
    field: 'salary',
    type: 'number',
  },

  stack: { field: 'stack' },
  currency: { field: 'currency' },
  city: { field: 'city' },
};

const domProps = {
  style: {
    height: '100%',
  },
};
const shouldReloadData = {
  sortInfo: true,
  filterValue: true,
};

// fetch an array of cities from the server
const citiesDataSource: DataSourceData<City> = () => {
  const cityNames = new Set<string>();
  const result: City[] = [];
  return fetch(process.env.NEXT_PUBLIC_BASE_URL + `/developers1k-sql`)
    .then((response) => response.json())
    .then((response) => {
      response.data.forEach((data: Developer) => {
        if (cityNames.has(data.city)) {
          return;
        }
        cityNames.add(data.city);
        result.push({
          name: data.city,
          country: data.country,
          id: result.length,
        });
      });

      return result;
    });
};

const detailDataSource: DataSourceData<Developer> = ({
  filterValue,
  sortInfo,
  masterRowInfo,
}) => {
  if (sortInfo && !Array.isArray(sortInfo)) {
    sortInfo = [sortInfo];
  }

  if (!filterValue) {
    filterValue = [];
  }
  if (masterRowInfo) {
    // filter by master country and city
    filterValue = [
      {
        field: 'city',
        filter: {
          operator: 'eq',
          type: 'string',
          value: masterRowInfo.data.name,
        },
      },
      {
        field: 'country',
        filter: {
          operator: 'eq',
          type: 'string',
          value: masterRowInfo.data.country,
        },
      },
      ...filterValue,
    ];
  }
  const args = [
    sortInfo
      ? 'sortInfo=' +
        JSON.stringify(
          sortInfo.map((s) => ({
            field: s.field,
            dir: s.dir,
          })),
        )
      : null,

    filterValue
      ? 'filterBy=' +
        JSON.stringify(
          filterValue.map(({ field, filter }) => {
            return {
              field: field,
              operator: filter.operator,
              value:
                filter.type === 'number' ? Number(filter.value) : filter.value,
            };
          }),
        )
      : null,
  ]
    .filter(Boolean)
    .join('&');

  return fetch(process.env.NEXT_PUBLIC_BASE_URL + `/developers1k-sql?` + args)
    .then((r) => r.json())
    .then((data: Developer[]) => data);
};

@Component({
  selector: 'demo-root',
  imports: [DataSource, InfiniteTable],
  template: `
    <infinite-data-source
      [data]="citiesDataSource"
      primaryKey="id"
      [defaultSortInfo]="[
        {
          field: 'country',
          dir: 1,
        },
        {
          field: 'name',
          dir: 1,
        },
      ]"
    >
      <infinite-table
        debugId="master-detail-example-2"
        [domProps]="domProps"
        [columnDefaultWidth]="150"
        [columnMinWidth]="50"
        [columns]="masterColumns"
        [rowDetailRenderer]="renderDetail"
      />
    </infinite-data-source>

    
    <ng-template #detail>
      <infinite-data-source
        [data]="detailDataSource"
        primaryKey="id"
        [shouldReloadData]="shouldReloadData"
      >
        <infinite-table
          debugId="master-detail-example"
          [columnDefaultWidth]="150"
          [columnMinWidth]="50"
          [columns]="detailColumns"
        />
      </infinite-data-source>
    </ng-template>
  `,
})
export default class App {
  protected readonly citiesDataSource = citiesDataSource;
  protected readonly detailDataSource = detailDataSource;
  protected readonly masterColumns = masterColumns;
  protected readonly detailColumns = detailColumns;
  protected readonly domProps = domProps;
  protected readonly shouldReloadData = shouldReloadData;

  private readonly detailTemplate =
    viewChild.required<TemplateRef<unknown>>('detail');

  // a field, so the grid gets the same function every time
  protected readonly renderDetail = (rowInfo: InfiniteTableRowInfo<City>) => {
    console.log('rendering detail for master row', rowInfo.id);
    return this.detailTemplate();
  };
}
```

### showColumnFilters (`boolean`)

> Whether to show the column filters or not (only applicable when the `<DataSource>` is configured with filtering - either with [`defaultFilterValue`](https://infinite-table.com/angular/docs/reference/datasource-props/index.md#defaultFilterValue) or [`[(filterValue)]`](https://infinite-table.com/angular/docs/reference/datasource-props/index.md#filterValue)).

When the `<DataSource>` is configured with [`defaultFilterValue`](https://infinite-table.com/angular/docs/reference/datasource-props/index.md#defaultFilterValue), the column filters will be shown by default. Specify this prop as `false` to hide the column filters.

**Example: Controling the visibility of column filters**

```ts
import { Component, signal } from '@angular/core';

import { DataSource, InfiniteTable } from '@infinite-table/infinite-angular';
import type {
  DataSourceData,
  DataSourcePropFilterValue,
  InfiniteTablePropColumns,
} from '@infinite-table/infinite-angular';

type Developer = {
  id: number;
  firstName: string;
  lastName: string;

  currency: string;
  preferredLanguage: string;
  stack: string;
  canDesign: 'yes' | 'no';

  salary: number;
};

const data: DataSourceData<Developer> = () => {
  return fetch(process.env.NEXT_PUBLIC_BASE_URL + `/developers1k-sql?`)
    .then((r) => r.json())
    .then((data: Developer[]) => data);
};

const columns: InfiniteTablePropColumns<Developer> = {
  id: {
    field: 'id',
    type: 'number',
    defaultWidth: 100,
  },
  salary: {
    field: 'salary',
    type: 'number',
  },

  firstName: {
    field: 'firstName',
  },
  stack: { field: 'stack' },
  currency: { field: 'currency', defaultFilterable: false },
};

const defaultFilterValue: DataSourcePropFilterValue<Developer> = [];

@Component({
  selector: 'demo-root',
  imports: [DataSource, InfiniteTable],
  template: `
    <div style="padding-block: 10px">
      <button (click)="showColumnFilters.set(!showColumnFilters())">
        Toggle visibility of column filters
      </button>
    </div>
    <infinite-data-source
      [data]="data"
      primaryKey="id"
      [defaultFilterValue]="defaultFilterValue"
      [filterDelay]="0"
    >
      <infinite-table
        debugId="column-filters-visibility-example"
        [columnDefaultWidth]="150"
        [columnMinWidth]="50"
        [columns]="columns"
        [showColumnFilters]="showColumnFilters()"
      />
    </infinite-data-source>
  `,
})
export default class App {
  protected readonly data = data;
  protected readonly columns = columns;
  protected readonly defaultFilterValue = defaultFilterValue;

  protected readonly showColumnFilters = signal(true);
}
```

### defaultRowDetailState (`RowDetailState`)

> Specifies the default expanded/collapsed state of row details.

For the controlled version, see [`[(rowDetailState)]`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#rowDetailState).

If [`isRowDetailExpanded`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#isRowDetailExpanded) is specified, it has the last word in deciding if a row detail is expanded or not, so it overrides the `defaultRowDetailState`.

Some of the rows in the master DataGrid are expanded by default.

**Example: Master detail DataGrid with some row details expanded by default**

```ts
import { Component, TemplateRef, viewChild } from '@angular/core';

import { DataSource, InfiniteTable } from '@infinite-table/infinite-angular';
import type {
  DataSourceData,
  InfiniteTablePropColumns,
  InfiniteTableRowInfo,
} from '@infinite-table/infinite-angular';

type Developer = {
  id: number;
  firstName: string;
  lastName: string;

  city: string;
  currency: string;
  country: string;
  preferredLanguage: string;
  stack: string;
  canDesign: 'yes' | 'no';

  salary: number;
};

type City = {
  id: number;
  name: string;
  country: string;
};

const masterColumns: InfiniteTablePropColumns<City> = {
  id: {
    field: 'id',
    header: 'ID',
    defaultWidth: 70,
    renderRowDetailIcon: true,
  },
  country: { field: 'country', header: 'Country' },
  city: { field: 'name', header: 'City', defaultFlex: 1 },
};

const detailColumns: InfiniteTablePropColumns<Developer> = {
  firstName: {
    field: 'firstName',
    header: 'First Name',
  },
  salary: {
    field: 'salary',
    type: 'number',
  },

  stack: { field: 'stack' },
  currency: { field: 'currency' },
  city: { field: 'city' },
};

const domProps = {
  style: {
    height: '100%',
  },
};
const shouldReloadData = {
  sortInfo: true,
  filterValue: true,
};

const defaultRowDetailState = {
  collapsedRows: true as const,
  expandedRows: [39, 54],
};

// fetch an array of cities from the server
const citiesDataSource: DataSourceData<City> = () => {
  const cityNames = new Set<string>();
  const result: City[] = [];
  return fetch(process.env.NEXT_PUBLIC_BASE_URL + `/developers1k-sql`)
    .then((response) => response.json())
    .then((response) => {
      response.data.forEach((data: Developer) => {
        if (cityNames.has(data.city)) {
          return;
        }
        cityNames.add(data.city);
        result.push({
          name: data.city,
          country: data.country,
          id: result.length,
        });
      });

      return result;
    });
};

const detailDataSource: DataSourceData<Developer> = ({
  filterValue,
  sortInfo,
  masterRowInfo,
}) => {
  if (sortInfo && !Array.isArray(sortInfo)) {
    sortInfo = [sortInfo];
  }

  if (!filterValue) {
    filterValue = [];
  }
  if (masterRowInfo) {
    // filter by master country and city
    filterValue = [
      {
        field: 'city',
        filter: {
          operator: 'eq',
          type: 'string',
          value: masterRowInfo.data.name,
        },
      },
      {
        field: 'country',
        filter: {
          operator: 'eq',
          type: 'string',
          value: masterRowInfo.data.country,
        },
      },
      ...filterValue,
    ];
  }
  const args = [
    sortInfo
      ? 'sortInfo=' +
        JSON.stringify(
          sortInfo.map((s) => ({
            field: s.field,
            dir: s.dir,
          })),
        )
      : null,

    filterValue
      ? 'filterBy=' +
        JSON.stringify(
          filterValue.map(({ field, filter }) => {
            return {
              field: field,
              operator: filter.operator,
              value:
                filter.type === 'number' ? Number(filter.value) : filter.value,
            };
          }),
        )
      : null,
  ]
    .filter(Boolean)
    .join('&');

  return fetch(process.env.NEXT_PUBLIC_BASE_URL + `/developers1k-sql?` + args)
    .then((r) => r.json())
    .then((data: Developer[]) => data);
};

@Component({
  selector: 'demo-root',
  imports: [DataSource, InfiniteTable],
  template: `
    <infinite-data-source
      [data]="citiesDataSource"
      primaryKey="id"
      [defaultSortInfo]="[
        {
          field: 'country',
          dir: 1,
        },
        {
          field: 'name',
          dir: 1,
        },
      ]"
    >
      <infinite-table
        debugId="master-detail-default-expanded-example-2"
        [domProps]="domProps"
        [columnDefaultWidth]="150"
        [columnMinWidth]="50"
        [defaultRowDetailState]="defaultRowDetailState"
        [columns]="masterColumns"
        [rowDetailHeight]="200"
        [rowDetailRenderer]="renderDetail"
      />
    </infinite-data-source>

    
    <ng-template #detail>
      <infinite-data-source
        [data]="detailDataSource"
        primaryKey="id"
        [shouldReloadData]="shouldReloadData"
      >
        <infinite-table
          debugId="master-detail-default-expanded-example"
          [columnDefaultWidth]="150"
          [columnMinWidth]="50"
          [columns]="detailColumns"
        />
      </infinite-data-source>
    </ng-template>
  `,
})
export default class App {
  protected readonly citiesDataSource = citiesDataSource;
  protected readonly detailDataSource = detailDataSource;
  protected readonly masterColumns = masterColumns;
  protected readonly detailColumns = detailColumns;
  protected readonly domProps = domProps;
  protected readonly shouldReloadData = shouldReloadData;
  protected readonly defaultRowDetailState = defaultRowDetailState;

  private readonly detailTemplate =
    viewChild.required<TemplateRef<unknown>>('detail');

  // a field, so the grid gets the same function every time
  protected readonly renderDetail = (rowInfo: InfiniteTableRowInfo<City>) => {
    console.log('rendering detail for master row', rowInfo.id);
    return this.detailTemplate();
  };
}
```

### isRowDetailExpanded (`(rowInfo: InfiniteTableRowInfo) => boolean`)

> This function ultimately decides if a row detail is expanded or not.

This function is meant for very advanced scenarios. For common use-cases, you'll probably use [`[(rowDetailState)]`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#rowDetailState) and [`defaultRowDetailState`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#defaultRowDetailState).

If `isRowDetailExpanded` is specified, it overrides [`[(rowDetailState)]`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#rowDetailState)/[`defaultRowDetailState`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#defaultRowDetailState).

### isRowDetailEnabled (`(rowInfo: InfiniteTableRowInfo<DATA_TYPE>) => boolean`)

> Decides on a per-row basis if the row details are enabled or not. See [Master Detail](https://infinite-table.com/angular/docs/learn/master-detail/overview.md) for more information.

This function is called with the [rowInfo](https://infinite-table.com/docs/reference/type-definitions/index.md#InfiniteTableRowInfo) and should return a `boolean` value.

It's useful when you don't want to show the row detail for some rows.

All the odd rows don't have details.

**Example: Master detail DataGrid with some row not having details**

```ts
import { Component, TemplateRef, viewChild } from '@angular/core';

import { DataSource, InfiniteTable } from '@infinite-table/infinite-angular';
import type {
  DataSourceData,
  InfiniteTablePropColumns,
  InfiniteTableRowInfo,
} from '@infinite-table/infinite-angular';

type Developer = {
  id: number;
  firstName: string;
  lastName: string;

  city: string;
  currency: string;
  country: string;
  preferredLanguage: string;
  stack: string;
  canDesign: 'yes' | 'no';

  salary: number;
};

type City = {
  id: number;
  name: string;
  country: string;
};

const masterColumns: InfiniteTablePropColumns<City> = {
  id: {
    field: 'id',
    header: 'ID',
    defaultWidth: 70,
    renderRowDetailIcon: true,
  },
  country: { field: 'country', header: 'Country' },
  city: { field: 'name', header: 'City', defaultFlex: 1 },
};

const detailColumns: InfiniteTablePropColumns<Developer> = {
  firstName: {
    field: 'firstName',
    header: 'First Name',
  },
  salary: {
    field: 'salary',
    type: 'number',
  },

  stack: { field: 'stack' },
  currency: { field: 'currency' },
  city: { field: 'city' },
};

const domProps = {
  style: {
    height: '100%',
  },
};
const shouldReloadData = {
  sortInfo: true,
  filterValue: true,
};

const isRowDetailEnabled = (rowInfo: InfiniteTableRowInfo<City>) => {
  return rowInfo.indexInAll % 2 === 0;
};

// fetch an array of cities from the server
const citiesDataSource: DataSourceData<City> = () => {
  const cityNames = new Set<string>();
  const result: City[] = [];
  return fetch(process.env.NEXT_PUBLIC_BASE_URL + `/developers1k-sql`)
    .then((response) => response.json())
    .then((response) => {
      response.data.forEach((data: Developer) => {
        if (cityNames.has(data.city)) {
          return;
        }
        cityNames.add(data.city);
        result.push({
          name: data.city,
          country: data.country,
          id: result.length,
        });
      });

      return result;
    });
};

const detailDataSource: DataSourceData<Developer> = ({
  filterValue,
  sortInfo,
  masterRowInfo,
}) => {
  if (sortInfo && !Array.isArray(sortInfo)) {
    sortInfo = [sortInfo];
  }

  if (!filterValue) {
    filterValue = [];
  }
  if (masterRowInfo) {
    // filter by master country and city
    filterValue = [
      {
        field: 'city',
        filter: {
          operator: 'eq',
          type: 'string',
          value: masterRowInfo.data.name,
        },
      },
      {
        field: 'country',
        filter: {
          operator: 'eq',
          type: 'string',
          value: masterRowInfo.data.country,
        },
      },
      ...filterValue,
    ];
  }
  const args = [
    sortInfo
      ? 'sortInfo=' +
        JSON.stringify(
          sortInfo.map((s) => ({
            field: s.field,
            dir: s.dir,
          })),
        )
      : null,

    filterValue
      ? 'filterBy=' +
        JSON.stringify(
          filterValue.map(({ field, filter }) => {
            return {
              field: field,
              operator: filter.operator,
              value:
                filter.type === 'number' ? Number(filter.value) : filter.value,
            };
          }),
        )
      : null,
  ]
    .filter(Boolean)
    .join('&');

  return fetch(process.env.NEXT_PUBLIC_BASE_URL + `/developers1k-sql?` + args)
    .then((r) => r.json())
    .then((data: Developer[]) => data);
};

@Component({
  selector: 'demo-root',
  imports: [DataSource, InfiniteTable],
  template: `
    <infinite-data-source
      [data]="citiesDataSource"
      primaryKey="id"
      [defaultSortInfo]="[
        {
          field: 'country',
          dir: 1,
        },
        {
          field: 'name',
          dir: 1,
        },
      ]"
    >
      <infinite-table
        debugId="master-detail-per-row-example-2"
        [domProps]="domProps"
        [columnDefaultWidth]="150"
        [columnMinWidth]="50"
        [columns]="masterColumns"
        [rowDetailRenderer]="renderDetail"
        [isRowDetailEnabled]="isRowDetailEnabled"
      />
    </infinite-data-source>

    
    <ng-template #detail>
      <infinite-data-source
        [data]="detailDataSource"
        primaryKey="id"
        [shouldReloadData]="shouldReloadData"
      >
        <infinite-table
          debugId="master-detail-per-row-example"
          [columnDefaultWidth]="150"
          [columnMinWidth]="50"
          [columns]="detailColumns"
        />
      </infinite-data-source>
    </ng-template>
  `,
})
export default class App {
  protected readonly citiesDataSource = citiesDataSource;
  protected readonly detailDataSource = detailDataSource;
  protected readonly masterColumns = masterColumns;
  protected readonly detailColumns = detailColumns;
  protected readonly domProps = domProps;
  protected readonly shouldReloadData = shouldReloadData;
  protected readonly isRowDetailEnabled = isRowDetailEnabled;

  private readonly detailTemplate =
    viewChild.required<TemplateRef<unknown>>('detail');

  // a field, so the grid gets the same function every time
  protected readonly renderDetail = (rowInfo: InfiniteTableRowInfo<City>) => {
    console.log('rendering detail for master row', rowInfo.id);
    return this.detailTemplate();
  };
}
```

### rowDetailState (`RowDetailState`)

> Specifies the expanded/collapsed state of row details.

For the uncontrolled version, see [`defaultRowDetailState`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#defaultRowDetailState).

When you use this controlled property, make sure you pair it with the [`(rowDetailStateChange)`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#onRowDetailStateChange) callback to update it.

If [`isRowDetailExpanded`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#isRowDetailExpanded) is specified, it has the final say in deciding if a row detail is expanded or not, so it overrides the `rowDetailState` and [`defaultRowDetailState`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#defaultRowDetailState).

Some of the rows in the master DataGrid are expanded by default.

**Example: Master detail DataGrid with some row details expanded by default**

```ts
import { Component, TemplateRef, signal, viewChild } from '@angular/core';
import { JsonPipe } from '@angular/common';

import {
  DataSource,
  InfiniteTable,
  RowDetailState,
} from '@infinite-table/infinite-angular';
import type {
  DataSourceData,
  InfiniteTableApi,
  InfiniteTablePropColumns,
  InfiniteTableRowInfo,
  RowDetailStateObject,
} from '@infinite-table/infinite-angular';

type Developer = {
  id: number;
  firstName: string;
  lastName: string;

  city: string;
  currency: string;
  country: string;
  preferredLanguage: string;
  stack: string;
  canDesign: 'yes' | 'no';

  salary: number;
};

type City = {
  id: number;
  name: string;
  country: string;
};

const masterColumns: InfiniteTablePropColumns<City> = {
  id: {
    field: 'id',
    header: 'ID',
    defaultWidth: 70,
    renderRowDetailIcon: true,
  },
  country: { field: 'country', header: 'Country' },
  city: { field: 'name', header: 'City', defaultFlex: 1 },
};

const detailColumns: InfiniteTablePropColumns<Developer> = {
  firstName: {
    field: 'firstName',
    header: 'First Name',
  },
  salary: {
    field: 'salary',
    type: 'number',
  },

  stack: { field: 'stack' },
  currency: { field: 'currency' },
  city: { field: 'city' },
};

const domProps = {
  style: {
    height: '100%',
  },
};
const shouldReloadData = {
  sortInfo: true,
  filterValue: true,
};

// fetch an array of cities from the server
const citiesDataSource: DataSourceData<City> = () => {
  const cityNames = new Set<string>();
  const result: City[] = [];
  return fetch(process.env.NEXT_PUBLIC_BASE_URL + `/developers1k-sql`)
    .then((response) => response.json())
    .then((response) => {
      response.data.forEach((data: Developer) => {
        if (cityNames.has(data.city)) {
          return;
        }
        cityNames.add(data.city);
        result.push({
          name: data.city,
          country: data.country,
          id: result.length,
        });
      });

      return result;
    });
};

const detailDataSource: DataSourceData<Developer> = ({
  filterValue,
  sortInfo,
  masterRowInfo,
}) => {
  if (sortInfo && !Array.isArray(sortInfo)) {
    sortInfo = [sortInfo];
  }

  if (!filterValue) {
    filterValue = [];
  }
  if (masterRowInfo) {
    // filter by master country and city
    filterValue = [
      {
        field: 'city',
        filter: {
          operator: 'eq',
          type: 'string',
          value: masterRowInfo.data.name,
        },
      },
      {
        field: 'country',
        filter: {
          operator: 'eq',
          type: 'string',
          value: masterRowInfo.data.country,
        },
      },
      ...filterValue,
    ];
  }
  const args = [
    sortInfo
      ? 'sortInfo=' +
        JSON.stringify(
          sortInfo.map((s) => ({
            field: s.field,
            dir: s.dir,
          })),
        )
      : null,

    filterValue
      ? 'filterBy=' +
        JSON.stringify(
          filterValue.map(({ field, filter }) => {
            return {
              field: field,
              operator: filter.operator,
              value:
                filter.type === 'number' ? Number(filter.value) : filter.value,
            };
          }),
        )
      : null,
  ]
    .filter(Boolean)
    .join('&');

  return fetch(process.env.NEXT_PUBLIC_BASE_URL + `/developers1k-sql?` + args)
    .then((r) => r.json())
    .then((data: Developer[]) => data);
};

@Component({
  selector: 'demo-root',
  imports: [DataSource, InfiniteTable, JsonPipe],
  template: `
    <code
      style="padding: 10px; color: var(--infinite-cell-color); background: var(--infinite-background); max-height: 200px; overflow: auto"
    >
      <pre>Row detail state: {{ rowDetailState() | json }}</pre>
    </code>
    <infinite-data-source
      [data]="citiesDataSource"
      primaryKey="id"
      [defaultSortInfo]="[
        {
          field: 'country',
          dir: 1,
        },
        {
          field: 'name',
          dir: 1,
        },
      ]"
    >
      <infinite-table
        debugId="master-detail-controlled-expanded-example-2"
        [domProps]="domProps"
        (ready)="onReady($event)"
        [columnDefaultWidth]="150"
        [rowDetailState]="rowDetailState()"
        (rowDetailStateChange)="onRowDetailStateChange($event)"
        [columnMinWidth]="50"
        [columns]="masterColumns"
        [rowDetailHeight]="200"
        [rowDetailRenderer]="renderDetail"
      />
    </infinite-data-source>

    
    <ng-template #detail>
      <infinite-data-source
        [data]="detailDataSource"
        primaryKey="id"
        [shouldReloadData]="shouldReloadData"
      >
        <infinite-table
          debugId="master-detail-controlled-expanded-example"
          [columnDefaultWidth]="150"
          [columnMinWidth]="50"
          [columns]="detailColumns"
        />
      </infinite-data-source>
    </ng-template>
  `,
})
export default class App {
  protected readonly citiesDataSource = citiesDataSource;
  protected readonly detailDataSource = detailDataSource;
  protected readonly masterColumns = masterColumns;
  protected readonly detailColumns = detailColumns;
  protected readonly domProps = domProps;
  protected readonly shouldReloadData = shouldReloadData;

  
  protected readonly rowDetailState = signal<RowDetailStateObject<any>>({
    collapsedRows: true as const,
    expandedRows: [39, 54],
  });

  // the grid emits a RowDetailState instance: store its plain object
  protected onRowDetailStateChange(
    rowDetailState: RowDetailState | RowDetailStateObject | undefined,
  ) {
    if (rowDetailState) {
      this.rowDetailState.set(
        rowDetailState instanceof RowDetailState
          ? rowDetailState.getState()
          : rowDetailState,
      );
    }
  }

  protected onReady({ api }: { api: InfiniteTableApi<City> }) {
    console.log(api.rowDetailApi);
  }

  private readonly detailTemplate =
    viewChild.required<TemplateRef<unknown>>('detail');

  // a field, so the grid gets the same function every time
  protected readonly renderDetail = (rowInfo: InfiniteTableRowInfo<City>) => {
    console.log('rendering detail for master row', rowInfo.id);
    return this.detailTemplate();
  };
}
```

### onRowDetailStateChange (`(rowDetailState: RowDetailState, {expandRow, collapseRow}) => void`)

> Called when the expand/collapse state of row details changes.

You can use this function prop to update the [`[(rowDetailState)]`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#rowDetailState) prop or simply to listen to changes in the row details state.

This function is called with an instance of the [`RowDetailState`](https://infinite-table.com/docs/reference/type-definitions/index.md#RowDetailState). If you want to get the object behind it, simply call `rowDetailState.getState()`.

Both the `RowDetailState` instance and the state object (literal) are valid values you can pass to the [`[(rowDetailState)]`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#rowDetailState).

The second parameter of this function is an object with `expandRow` and `collapseRow` properties, which contain the primary key of either the last expanded or the last collapsed row.

For example, if the user is expanding row `3`, the object will be `{expandRow: 3, collapseRow: null}`.
Next, if the user collapses row `5`, the object will be `{expandRow: null, collapseRow: 5}`.

This makes it easy for you to know which action was taken and on which row.

See related [`[(rowDetailState)]`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#rowDetailState) and [`defaultRowDetailState`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#defaultRowDetailState).

Some of the rows in the master DataGrid are expanded by default.

**Example: Master detail DataGrid with listener to the row expand/collapse state change**

```ts
import { Component, TemplateRef, signal, viewChild } from '@angular/core';
import { JsonPipe } from '@angular/common';

import {
  DataSource,
  InfiniteTable,
  RowDetailState,
} from '@infinite-table/infinite-angular';
import type {
  DataSourceData,
  InfiniteTableApi,
  InfiniteTablePropColumns,
  InfiniteTableRowInfo,
  RowDetailStateObject,
} from '@infinite-table/infinite-angular';

type Developer = {
  id: number;
  firstName: string;
  lastName: string;

  city: string;
  currency: string;
  country: string;
  preferredLanguage: string;
  stack: string;
  canDesign: 'yes' | 'no';

  salary: number;
};

type City = {
  id: number;
  name: string;
  country: string;
};

const masterColumns: InfiniteTablePropColumns<City> = {
  id: {
    field: 'id',
    header: 'ID',
    defaultWidth: 70,
    renderRowDetailIcon: true,
  },
  country: { field: 'country', header: 'Country' },
  city: { field: 'name', header: 'City', defaultFlex: 1 },
};

const detailColumns: InfiniteTablePropColumns<Developer> = {
  firstName: {
    field: 'firstName',
    header: 'First Name',
  },
  salary: {
    field: 'salary',
    type: 'number',
  },

  stack: { field: 'stack' },
  currency: { field: 'currency' },
  city: { field: 'city' },
};

const domProps = {
  style: {
    height: '100%',
  },
};
const shouldReloadData = {
  sortInfo: true,
  filterValue: true,
};

// fetch an array of cities from the server
const citiesDataSource: DataSourceData<City> = () => {
  const cityNames = new Set<string>();
  const result: City[] = [];
  return fetch(process.env.NEXT_PUBLIC_BASE_URL + `/developers1k-sql`)
    .then((response) => response.json())
    .then((response) => {
      response.data.forEach((data: Developer) => {
        if (cityNames.has(data.city)) {
          return;
        }
        cityNames.add(data.city);
        result.push({
          name: data.city,
          country: data.country,
          id: result.length,
        });
      });

      return result;
    });
};

const detailDataSource: DataSourceData<Developer> = ({
  filterValue,
  sortInfo,
  masterRowInfo,
}) => {
  if (sortInfo && !Array.isArray(sortInfo)) {
    sortInfo = [sortInfo];
  }

  if (!filterValue) {
    filterValue = [];
  }
  if (masterRowInfo) {
    // filter by master country and city
    filterValue = [
      {
        field: 'city',
        filter: {
          operator: 'eq',
          type: 'string',
          value: masterRowInfo.data.name,
        },
      },
      {
        field: 'country',
        filter: {
          operator: 'eq',
          type: 'string',
          value: masterRowInfo.data.country,
        },
      },
      ...filterValue,
    ];
  }
  const args = [
    sortInfo
      ? 'sortInfo=' +
        JSON.stringify(
          sortInfo.map((s) => ({
            field: s.field,
            dir: s.dir,
          })),
        )
      : null,

    filterValue
      ? 'filterBy=' +
        JSON.stringify(
          filterValue.map(({ field, filter }) => {
            return {
              field: field,
              operator: filter.operator,
              value:
                filter.type === 'number' ? Number(filter.value) : filter.value,
            };
          }),
        )
      : null,
  ]
    .filter(Boolean)
    .join('&');

  return fetch(process.env.NEXT_PUBLIC_BASE_URL + `/developers1k-sql?` + args)
    .then((r) => r.json())
    .then((data: Developer[]) => data);
};

@Component({
  selector: 'demo-root',
  imports: [DataSource, InfiniteTable, JsonPipe],
  template: `
    <code
      style="padding: 10px; color: var(--infinite-cell-color); background: var(--infinite-background); max-height: 200px; overflow: auto"
    >
      <pre>Row detail state: {{ rowDetailState() | json }}</pre>
    </code>
    <infinite-data-source
      [data]="citiesDataSource"
      primaryKey="id"
      [defaultSortInfo]="[
        {
          field: 'country',
          dir: 1,
        },
        {
          field: 'name',
          dir: 1,
        },
      ]"
    >
      <infinite-table
        debugId="master-detail-controlled-expanded-example-2"
        [domProps]="domProps"
        (ready)="onReady($event)"
        [columnDefaultWidth]="150"
        [rowDetailState]="rowDetailState()"
        (rowDetailStateChange)="onRowDetailStateChange($event)"
        [columnMinWidth]="50"
        [columns]="masterColumns"
        [rowDetailHeight]="200"
        [rowDetailRenderer]="renderDetail"
      />
    </infinite-data-source>

    
    <ng-template #detail>
      <infinite-data-source
        [data]="detailDataSource"
        primaryKey="id"
        [shouldReloadData]="shouldReloadData"
      >
        <infinite-table
          debugId="master-detail-controlled-expanded-example"
          [columnDefaultWidth]="150"
          [columnMinWidth]="50"
          [columns]="detailColumns"
        />
      </infinite-data-source>
    </ng-template>
  `,
})
export default class App {
  protected readonly citiesDataSource = citiesDataSource;
  protected readonly detailDataSource = detailDataSource;
  protected readonly masterColumns = masterColumns;
  protected readonly detailColumns = detailColumns;
  protected readonly domProps = domProps;
  protected readonly shouldReloadData = shouldReloadData;

  
  protected readonly rowDetailState = signal<RowDetailStateObject<any>>({
    collapsedRows: true as const,
    expandedRows: [39, 54],
  });

  // the grid emits a RowDetailState instance: store its plain object
  protected onRowDetailStateChange(
    rowDetailState: RowDetailState | RowDetailStateObject | undefined,
  ) {
    if (rowDetailState) {
      this.rowDetailState.set(
        rowDetailState instanceof RowDetailState
          ? rowDetailState.getState()
          : rowDetailState,
      );
    }
  }

  protected onReady({ api }: { api: InfiniteTableApi<City> }) {
    console.log(api.rowDetailApi);
  }

  private readonly detailTemplate =
    viewChild.required<TemplateRef<unknown>>('detail');

  // a field, so the grid gets the same function every time
  protected readonly renderDetail = (rowInfo: InfiniteTableRowInfo<City>) => {
    console.log('rendering detail for master row', rowInfo.id);
    return this.detailTemplate();
  };
}
```

### rowDetailCache (`boolean|number`)
> Controls the caching of detail DataGrids. By default, caching is disabled.

It can be one of the following:

- `false` - caching is disabled - this is the default
- `true` - enables caching for all detail DataGrids
- `number` - the maximum number of detail DataGrids to keep in the cache. When the limit is reached, the oldest detail DataGrid will be removed from the cache.

This example will cache the last 5 detail DataGrids - meaning they won't reload when you expand them again.
You can try collapsing a row and then expanding it again to see the caching in action - it won't reload the data.
But when you open up a row that hasn't been opened before, it will load the data from the remote location.

**Example: Master detail DataGrid with caching for 5 detail DataGrids**

```ts
import { Component, TemplateRef, viewChild } from '@angular/core';

import { DataSource, InfiniteTable } from '@infinite-table/infinite-angular';
import type {
  DataSourceData,
  InfiniteTablePropColumns,
  InfiniteTableRowInfo,
} from '@infinite-table/infinite-angular';

type Developer = {
  id: number;
  firstName: string;
  lastName: string;

  city: string;
  currency: string;
  country: string;
  preferredLanguage: string;
  stack: string;
  canDesign: 'yes' | 'no';

  salary: number;
};

type City = {
  id: number;
  name: string;
  country: string;
};

const masterColumns: InfiniteTablePropColumns<City> = {
  id: {
    field: 'id',
    header: 'ID',
    defaultWidth: 70,
    renderRowDetailIcon: true,
  },
  country: { field: 'country', header: 'Country' },
  city: { field: 'name', header: 'City', defaultFlex: 1 },
};

const detailColumns: InfiniteTablePropColumns<Developer> = {
  firstName: {
    field: 'firstName',
    header: 'First Name',
  },
  salary: {
    field: 'salary',
    type: 'number',
  },

  stack: { field: 'stack' },
  currency: { field: 'currency' },
  city: { field: 'city' },
};

const domProps = {
  style: {
    height: '100%',
  },
};
const shouldReloadData = {
  sortInfo: true,
  filterValue: true,
};

const defaultRowDetailState = {
  collapsedRows: true as const,
  expandedRows: [39, 54],
};

// fetch an array of cities from the server
const citiesDataSource: DataSourceData<City> = () => {
  const cityNames = new Set<string>();
  const result: City[] = [];
  return fetch(process.env.NEXT_PUBLIC_BASE_URL + `/developers1k-sql`)
    .then((response) => response.json())
    .then((response) => {
      response.data.forEach((data: Developer) => {
        if (cityNames.has(data.city)) {
          return;
        }
        cityNames.add(data.city);
        result.push({
          name: data.city,
          country: data.country,
          id: result.length,
        });
      });

      return result;
    });
};

const detailDataSource: DataSourceData<Developer> = ({
  filterValue,
  sortInfo,
  masterRowInfo,
}) => {
  if (sortInfo && !Array.isArray(sortInfo)) {
    sortInfo = [sortInfo];
  }

  if (!filterValue) {
    filterValue = [];
  }
  if (masterRowInfo) {
    // filter by master country and city
    filterValue = [
      {
        field: 'city',
        filter: {
          operator: 'eq',
          type: 'string',
          value: masterRowInfo.data.name,
        },
      },
      {
        field: 'country',
        filter: {
          operator: 'eq',
          type: 'string',
          value: masterRowInfo.data.country,
        },
      },
      ...filterValue,
    ];
  }
  const args = [
    sortInfo
      ? 'sortInfo=' +
        JSON.stringify(
          sortInfo.map((s) => ({
            field: s.field,
            dir: s.dir,
          })),
        )
      : null,

    filterValue
      ? 'filterBy=' +
        JSON.stringify(
          filterValue.map(({ field, filter }) => {
            return {
              field: field,
              operator: filter.operator,
              value:
                filter.type === 'number' ? Number(filter.value) : filter.value,
            };
          }),
        )
      : null,
  ]
    .filter(Boolean)
    .join('&');

  return fetch(process.env.NEXT_PUBLIC_BASE_URL + `/developers1k-sql?` + args)
    .then((r) => r.json())
    .then(
      (data: Developer[]) =>
        new Promise((resolve) => {
          setTimeout(() => {
            resolve(data);
          }, 500);
        }),
    );
};

@Component({
  selector: 'demo-root',
  imports: [DataSource, InfiniteTable],
  template: `
    <infinite-data-source
      [data]="citiesDataSource"
      primaryKey="id"
      [defaultSortInfo]="[
        {
          field: 'country',
          dir: 1,
        },
        {
          field: 'name',
          dir: 1,
        },
      ]"
    >
      <infinite-table
        debugId="master-detail-caching-with-default-expanded-example-2"
        [domProps]="domProps"
        [columnDefaultWidth]="150"
        [columnMinWidth]="50"
        [defaultRowDetailState]="defaultRowDetailState"
        [columns]="masterColumns"
        [rowDetailCache]="5"
        [rowDetailHeight]="200"
        [rowDetailRenderer]="renderDetail"
      />
    </infinite-data-source>

    
    <ng-template #detail>
      <infinite-data-source
        [data]="detailDataSource"
        primaryKey="id"
        [shouldReloadData]="shouldReloadData"
      >
        <infinite-table
          debugId="master-detail-caching-with-default-expanded-example"
          [columnDefaultWidth]="150"
          [columnMinWidth]="50"
          [columns]="detailColumns"
        />
      </infinite-data-source>
    </ng-template>
  `,
})
export default class App {
  protected readonly citiesDataSource = citiesDataSource;
  protected readonly detailDataSource = detailDataSource;
  protected readonly masterColumns = masterColumns;
  protected readonly detailColumns = detailColumns;
  protected readonly domProps = domProps;
  protected readonly shouldReloadData = shouldReloadData;
  protected readonly defaultRowDetailState = defaultRowDetailState;

  private readonly detailTemplate =
    viewChild.required<TemplateRef<unknown>>('detail');

  // a field, so the grid gets the same function every time
  protected readonly renderDetail = (rowInfo: InfiniteTableRowInfo<City>) => {
    console.log('rendering detail for master row', rowInfo.id);
    return this.detailTemplate();
  };
}
```

### rowDetailHeight (`number|CSSVar|(rowInfo)=>number`)

> Controls the height of the row details section, in master-detail DataGrids.

The default value is `300` pixels.

This can be a number, a string (the name of a CSS variable - eg `--detail-height`), or a function. When a function is defined, it's called with the [rowInfo](https://infinite-table.com/docs/reference/type-definitions/index.md#InfiniteTableRowInfo) object for the corresponding row.

In this example we configure the height of row details to be 200px.

**Example: Master detail DataGrid with custom detail height**

```ts
import { Component, TemplateRef, viewChild } from '@angular/core';

import { DataSource, InfiniteTable } from '@infinite-table/infinite-angular';
import type {
  DataSourceData,
  InfiniteTablePropColumns,
  InfiniteTableRowInfo,
} from '@infinite-table/infinite-angular';

type Developer = {
  id: number;
  firstName: string;
  lastName: string;

  city: string;
  currency: string;
  country: string;
  preferredLanguage: string;
  stack: string;
  canDesign: 'yes' | 'no';

  salary: number;
};

type City = {
  id: number;
  name: string;
  country: string;
};

const masterColumns: InfiniteTablePropColumns<City> = {
  id: {
    field: 'id',
    header: 'ID',
    defaultWidth: 70,
    renderRowDetailIcon: true,
  },
  country: { field: 'country', header: 'Country' },
  city: { field: 'name', header: 'City', defaultFlex: 1 },
};

const detailColumns: InfiniteTablePropColumns<Developer> = {
  firstName: {
    field: 'firstName',
    header: 'First Name',
  },
  salary: {
    field: 'salary',
    type: 'number',
  },

  stack: { field: 'stack' },
  currency: { field: 'currency' },
  city: { field: 'city' },
};

const domProps = {
  style: {
    height: '100%',
  },
};
const shouldReloadData = {
  sortInfo: true,
  filterValue: true,
};

const defaultRowDetailState = {
  collapsedRows: true as const,
  expandedRows: [39, 54],
};

// fetch an array of cities from the server
const citiesDataSource: DataSourceData<City> = () => {
  const cityNames = new Set<string>();
  const result: City[] = [];
  return fetch(process.env.NEXT_PUBLIC_BASE_URL + `/developers1k-sql`)
    .then((response) => response.json())
    .then((response) => {
      response.data.forEach((data: Developer) => {
        if (cityNames.has(data.city)) {
          return;
        }
        cityNames.add(data.city);
        result.push({
          name: data.city,
          country: data.country,
          id: result.length,
        });
      });

      return result;
    });
};

const detailDataSource: DataSourceData<Developer> = ({
  filterValue,
  sortInfo,
  masterRowInfo,
}) => {
  if (sortInfo && !Array.isArray(sortInfo)) {
    sortInfo = [sortInfo];
  }

  if (!filterValue) {
    filterValue = [];
  }
  if (masterRowInfo) {
    // filter by master country and city
    filterValue = [
      {
        field: 'city',
        filter: {
          operator: 'eq',
          type: 'string',
          value: masterRowInfo.data.name,
        },
      },
      {
        field: 'country',
        filter: {
          operator: 'eq',
          type: 'string',
          value: masterRowInfo.data.country,
        },
      },
      ...filterValue,
    ];
  }
  const args = [
    sortInfo
      ? 'sortInfo=' +
        JSON.stringify(
          sortInfo.map((s) => ({
            field: s.field,
            dir: s.dir,
          })),
        )
      : null,

    filterValue
      ? 'filterBy=' +
        JSON.stringify(
          filterValue.map(({ field, filter }) => {
            return {
              field: field,
              operator: filter.operator,
              value:
                filter.type === 'number' ? Number(filter.value) : filter.value,
            };
          }),
        )
      : null,
  ]
    .filter(Boolean)
    .join('&');

  return fetch(process.env.NEXT_PUBLIC_BASE_URL + `/developers1k-sql?` + args)
    .then((r) => r.json())
    .then((data: Developer[]) => data);
};

@Component({
  selector: 'demo-root',
  imports: [DataSource, InfiniteTable],
  template: `
    <infinite-data-source
      [data]="citiesDataSource"
      primaryKey="id"
      [defaultSortInfo]="[
        {
          field: 'country',
          dir: 1,
        },
        {
          field: 'name',
          dir: 1,
        },
      ]"
    >
      <infinite-table
        debugId="master-detail-custom-detail-height-example-2"
        [domProps]="domProps"
        [columnDefaultWidth]="150"
        [columnMinWidth]="50"
        [defaultRowDetailState]="defaultRowDetailState"
        [columns]="masterColumns"
        [rowDetailHeight]="200"
        [rowDetailRenderer]="renderDetail"
      />
    </infinite-data-source>

    
    <ng-template #detail>
      <infinite-data-source
        [data]="detailDataSource"
        primaryKey="id"
        [shouldReloadData]="shouldReloadData"
      >
        <infinite-table
          debugId="master-detail-custom-detail-height-example"
          [columnDefaultWidth]="150"
          [columnMinWidth]="50"
          [columns]="detailColumns"
        />
      </infinite-data-source>
    </ng-template>
  `,
})
export default class App {
  protected readonly citiesDataSource = citiesDataSource;
  protected readonly detailDataSource = detailDataSource;
  protected readonly masterColumns = masterColumns;
  protected readonly detailColumns = detailColumns;
  protected readonly domProps = domProps;
  protected readonly shouldReloadData = shouldReloadData;
  protected readonly defaultRowDetailState = defaultRowDetailState;

  private readonly detailTemplate =
    viewChild.required<TemplateRef<unknown>>('detail');

  // a field, so the grid gets the same function every time
  protected readonly renderDetail = (rowInfo: InfiniteTableRowInfo<City>) => {
    console.log('rendering detail for master row', rowInfo.id);
    return this.detailTemplate();
  };
}
```

### activeCellIndex (`[number,number] | null`)

> Specifies the active cell for keyboard navigation. This is a controlled prop. See the [Keyboard Navigation](https://infinite-table.com/angular/docs/learn/keyboard-navigation/navigating-cells.md) page for more details.

See [`defaultActiveCellIndex`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#defaultActiveCellIndex) for the uncontrolled version of this prop and [`keyboardNavigation`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#keyboardNavigation) for the keyboard navigation behavior.

Use the [`(activeCellIndexChange)`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#onActiveCellIndexChange) callback to be notified when the active cell changes.

`null` is a valid value, and it means no cell is currently rendered as active. Especially useful for controlled scenarios, when you need ultimate control over the behavior of keyboard navigation.

This example starts with cell `[2,0]` already active.

**Example: Controlled keyboard navigation for cells**

```ts
import { Component, signal } from '@angular/core';

import { InfiniteTable, DataSource } from '@infinite-table/infinite-angular';
import type {
  DataSourceData,
  InfiniteTablePropColumns,
} from '@infinite-table/infinite-angular';

type Developer = {
  id: number;
  firstName: string;
  lastName: string;
  country: string;
  city: string;
  currency: string;
  preferredLanguage: string;
  stack: string;
  canDesign: 'yes' | 'no';
  hobby: string;
  salary: number;
  age: number;
};

const dataSource: DataSourceData<Developer> = () => {
  return fetch(
    'https://infinite-table.com/.netlify/functions/json-server' +
      `/developers1k-sql?`,
  )
    .then((r) => r.json())
    .then((data: Developer[]) => data);
};

const columns: InfiniteTablePropColumns<Developer> = {
  preferredLanguage: { field: 'preferredLanguage' },
  country: { field: 'country' },
  salary: {
    field: 'salary',
    type: 'number',
  },
  age: { field: 'age' },
  canDesign: { field: 'canDesign' },
  firstName: { field: 'firstName' },
  stack: { field: 'stack' },
  id: { field: 'id' },
  hobby: { field: 'hobby' },
  city: { field: 'city' },
  currency: { field: 'currency' },
};

@Component({
  selector: 'demo-root',
  imports: [DataSource, InfiniteTable],
  template: `
    <div style="color: var(--infinite-cell-color)">
      Current active cell: {{ activeCellIndex()[0] }}, {{ activeCellIndex()[1] }}.
    </div>
    <infinite-data-source primaryKey="id" [data]="dataSource">
      <infinite-table
        debugId="navigating-cells-controlled-example"
        [(activeCellIndex)]="activeCellIndex"
        [columns]="columns"
      />
    </infinite-data-source>
  `,
})
export default class App {
  protected readonly dataSource = dataSource;
  protected readonly columns = columns;

  
  protected readonly activeCellIndex = signal<[number, number]>([2, 0]);
}
```

### activeRowIndex (`number | null`)

> Specifies the active row for keyboard navigation. This is a controlled prop. See the [Keyboard Navigation](https://infinite-table.com/angular/docs/learn/keyboard-navigation/navigating-rows.md) page for more details.

See [`defaultActiveRowIndex`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#defaultActiveRowIndex) for the uncontrolled version of this prop and [`keyboardNavigation`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#keyboardNavigation) for the keyboard navigation behavior.

Use the [`(activeRowIndexChange)`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#onActiveRowIndexChange) callback to be notified when the active row changes.

`null` is a valid value, and it means no row is currently rendered as active. Especially useful for controlled scenarios, when you need ultimate control over the behavior of keyboard navigation.

This example starts with row at index `2` already active.

**Example: Controlled keyboard navigation for rows**

```ts
import { Component, signal } from '@angular/core';

import { InfiniteTable, DataSource } from '@infinite-table/infinite-angular';
import type {
  DataSourceData,
  InfiniteTablePropColumns,
} from '@infinite-table/infinite-angular';

type Developer = {
  id: number;
  firstName: string;
  lastName: string;
  country: string;
  city: string;
  currency: string;
  preferredLanguage: string;
  stack: string;
  canDesign: 'yes' | 'no';
  hobby: string;
  salary: number;
  age: number;
};

const dataSource: DataSourceData<Developer> = () => {
  return fetch(
    'https://infinite-table.com/.netlify/functions/json-server' +
      `/developers1k-sql?`,
  )
    .then((r) => r.json())
    .then((data: Developer[]) => data);
};

const columns: InfiniteTablePropColumns<Developer> = {
  preferredLanguage: { field: 'preferredLanguage' },
  country: { field: 'country' },
  salary: {
    field: 'salary',
    type: 'number',
  },
  age: { field: 'age' },
  canDesign: { field: 'canDesign' },
  firstName: { field: 'firstName' },
  stack: { field: 'stack' },
  id: { field: 'id' },
  hobby: { field: 'hobby' },
  city: { field: 'city' },
  currency: { field: 'currency' },
};

@Component({
  selector: 'demo-root',
  imports: [DataSource, InfiniteTable],
  template: `
    <div style="color: var(--infinite-cell-color)">
      Current active row: {{ activeRowIndex() }}.
    </div>
    <infinite-data-source primaryKey="id" [data]="dataSource">
      <infinite-table
        debugId="navigating-rows-controlled-example"
        keyboardNavigation="row"
        [(activeRowIndex)]="activeRowIndex"
        [columns]="columns"
      />
    </infinite-data-source>
  `,
})
export default class App {
  protected readonly dataSource = dataSource;
  protected readonly columns = columns;

  
  protected readonly activeRowIndex = signal(2);
}
```

### autoSizeColumnsKey (`number|string|{key,includeHeader,columnsToSkip,columnsToResize}`)

> Controls auto-sizing of columns.

Here is a list of possible values for `autoSizeColumnsKey`:

- `string` or `number` - when the value is changing, all columns will be auto-sized.

- an object with a `key` property (of type `string` or `number`) - whenever the `key` changes, the columns will be auto-sized. Specifying an object for `autoSizeColumnsKey` gives you more control over which columns are auto-sized and if the size measurements include the header or not.

When an object is used, the following properties are available:

- `key` - mandatory property, which, when changed, triggers the update
- `includeHeader` - optional boolean, - decides whether the header will be included in the auto-sizing calculations. If not specified, `true` is assumed.
- `columnsToSkip` - a list of column ids to skip from auto-sizing. If this is used, all columns except those in the list will be auto-sized.
- `columnsToResize` - the list of column ids to include in auto-sizing. If this is used, only columns in the list will be auto-sized.

**Example: Auto-sizing columns**

```ts
import { Component, computed, signal } from '@angular/core';

import { DataSource, InfiniteTable } from '@infinite-table/infinite-angular';
import type { InfiniteTablePropColumns } from '@infinite-table/infinite-angular';

type Developer = {
  id: number;
  firstName: string;
  lastName: string;
  country: string;
  city: string;
  currency: string;
  preferredLanguage: string;
  stack: string;
  canDesign: 'yes' | 'no';
  hobby: string;
  salary: number;
  age: number;
};

const dataSource = () => {
  return fetch(process.env.NEXT_PUBLIC_BASE_URL + '/developers1k')
    .then((r) => r.json())
    .then((data: Developer[]) => data);
};

const columns: InfiniteTablePropColumns<Developer> = {
  id: { field: 'id' },
  firstName: { field: 'firstName' },
  preferredLanguage: { field: 'preferredLanguage' },
  stack: { field: 'stack' },
  country: { field: 'country' },
  age: { field: 'age', type: 'number' },
  salary: { field: 'salary', type: 'number' },
  currency: { field: 'currency', type: 'number' },
};

@Component({
  selector: 'demo-root',
  imports: [DataSource, InfiniteTable],
  template: `
    <div
      style="
        color: var(--infinite-cell-color);
        background: var(--infinite-background);
      "
    >
      <label>
        <input
          type="checkbox"
          [checked]="includeHeader()"
          (change)="includeHeader.set($any($event.target).checked)"
        />
        Include header
      </label>

      <button
        style="
          margin: 10px;
          padding: 10px;
          border-radius: 5px;
          border: 2px solid magenta;
        "
        (click)="key.set(key() + 1)"
      >
        Click to auto-size
      </button>
    </div>

    <infinite-data-source primaryKey="id" [data]="dataSource">
      <infinite-table
        debugId="autoSizeColumnsKey-example"
        [autoSizeColumnsKey]="autoSizeColumnsKey()"
        [columns]="columns"
        [columnDefaultWidth]="200"
      />
    </infinite-data-source>
  `,
})
export default class App {
  protected readonly dataSource = dataSource;
  protected readonly columns = columns;

  protected readonly key = signal(0);
  protected readonly includeHeader = signal(false);

  
  protected readonly autoSizeColumnsKey = computed(() => ({
    includeHeader: this.includeHeader(),
    key: this.key(),
  }));
}
```

When auto-sizing takes place, [`(columnSizingChange)`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#onColumnSizingChange) is called with the new column sizes. If you use controlled [`[(columnSizing)]`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#columnSizing), make sure you update its value accordingly.

When columns are auto-sized, keep in mind that only visible (rendered) rows are taken into account - so if you scroll new rows into view, auto-sizing columns may result in different column sizes.

In the same logic, keep in mind that by default columns are also virtualized (controlled by [`virtualizeColumns`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#virtualizeColumns)), not only rows, so only visible columns are auto-sized (in case you have more columns, the columns that are not currently visible do not change their sizes).

### columnDefaultEditable (`boolean`)

> Specifies whether columns are editable by default.

To enable editing globally, you can use this boolean prop on the `InfiniteTable` component. It will enable the editing on all columns.

Or you can be more specific and choose to make individual columns editable via the [column.defaultEditable](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#columns.defaultEditable) prop.

In addition to the props already in discussion, you can use the [`editable`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#editable) prop on the `InfiniteTable` component. This overrides all other properties and when it is defined, is the only source of truth for whether something is editable or not.

By default, double-clicking an editable cell will show the cell editor. You can prevent this by returning `{preventEdit: true}` from the [`[onCellDoubleClick]`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#onCellDoubleClick) function prop.

All columns are configured to not be editable, except the `salary` column.

```ts
import { Component } from '@angular/core';

import { DataSource, InfiniteTable } from '@infinite-table/infinite-angular';
import type { InfiniteTablePropColumns } from '@infinite-table/infinite-angular';

type Developer = {
  id: number;
  firstName: string;
  currency: string;
  stack: string;
  hobby: string;
  salary: string;
};
const dataSource: Developer[] = [
  {
    id: 1,
    firstName: 'John',
    currency: 'USD',
    stack: 'frontend',
    hobby: 'gaming',
    salary: 'USD 1000',
  },
  {
    id: 2,
    firstName: 'Jane',
    currency: 'EUR',
    stack: 'backend',
    hobby: 'reading',
    salary: 'EUR 2000',
  },
  {
    id: 3,
    firstName: 'Jack',
    currency: 'GBP',
    stack: 'frontend',
    hobby: 'gaming',
    salary: 'GBP 3000',
  },
  {
    id: 4,
    firstName: 'Jill',
    currency: 'USD',
    stack: 'backend',
    hobby: 'reading',
    salary: 'USD 4000',
  },
];

const columns: InfiniteTablePropColumns<Developer> = {
  id: { field: 'id', defaultWidth: 80 },

  salary: {
    // the only editable column
    defaultEditable: true,

    defaultWidth: 320,
    field: 'salary',
    header: 'Salary - edit accepts numbers only',
    style: { color: 'tomato' },
    getValueToEdit: ({ value }) => {
      return parseInt(value.substr(4), 10);
    },
    getValueToPersist: ({ value, data }) => {
      return `${data!.currency} ${parseInt(value, 10)}`;
    },
  },

  firstName: {
    field: 'firstName',
    header: 'Name',
  },
  currency: {
    field: 'currency',
    header: 'Currency',
  },
};

const shouldAcceptEdit = ({ value }: { value: any }) => {
  return parseInt(value, 10) == value;
};

@Component({
  selector: 'demo-root',
  imports: [DataSource, InfiniteTable],
  template: `
    <infinite-data-source primaryKey="id" [data]="dataSource">
      <infinite-table
        debugId="global-should-accept-edit-example"
        [columns]="columns"
        [columnDefaultEditable]="false"
        [shouldAcceptEdit]="shouldAcceptEdit"
      />
    </infinite-data-source>
  `,
})
export default class App {
  protected readonly dataSource = dataSource;
  protected readonly columns = columns;
  protected readonly shouldAcceptEdit = shouldAcceptEdit;
}
```

### columnDefaultSortable (`boolean`)

> Specifies whether columns are sortable by default.

This property is overriden by (in this order) the following props:

- [`columnTypes.defaultSortable`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#columnTypes.defaultSortable)
- [`column.defaultSortable`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#column.defaultSortable)
- [`sortable`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#sortable)

When specified, [`sortable`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#sortable) overrides all other properties and is the only source of truth for whether something is sortable or not.

This property does not apply for group columns, since for sorting, group columns generally depend on the columns they are grouping.

In some cases, you can have group columns that group by fields that are not bound to actual columns, so for determining sorting for group columns, use one of the following props:

- [`columnTypes.defaultSortable`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#columnTypes.defaultSortable)
- [`column.defaultSortable`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#column.defaultSortable)
- [`sortable`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#sortable)

### sortable (`boolean | ({column, columns, api, columnApi}) => boolean`)

> This prop is the ultimate source of truth on whether (and which) columns are sortable.

This property overrides all the following props:

- [`columnDefaultSortable`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#columnDefaultSortable) (this is the base value, overriden by all other props in this list, in this order)
- [`columnTypes.defaultSortable`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#columnTypes.defaultSortable)
- [`column.defaultSortable`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#column.defaultSortable)

The [`sortable`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#sortable) prop is designed to be used for highly advanced scenarios, where you need to have ultimate control over which columns are sortable and which are not - in this case, you will want to declare [`sortable`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#sortable) as a function, which returns `true/false` for every column.

### columnDefaultWidth (`number`)

> Specifies the a default width for all columns.

If a column is explicitly sized via [column.defaultWidth](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#columns.defaultWidth), [column.defaultFlex](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#columns.defaultFlex), [`columnSizing.width`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#columnSizing.width) (or [`defaultColumnSizing.width`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#defaultColumnSizing.width)), that will be used instead.

Use [`columnMinWidth`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#columnMinWidth) to set a minimum width for all columns.
Use [`columnMaxWidth`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#columnMaxWidth) to set a maximum width for all columns.

[`columnMinWidth`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#columnMinWidth) and [`columnMaxWidth`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#columnMaxWidth) will be very useful once flex column sizing lands.

```ts
import { Component } from '@angular/core';

import { DataSource, InfiniteTable } from '@infinite-table/infinite-angular';
import type { InfiniteTableColumn } from '@infinite-table/infinite-angular';

import { data } from './data';
import type { Person } from './data';

const columns: Record<string, InfiniteTableColumn<Person>> = {
  identifier: {
    field: 'Id',
    type: 'number',
    defaultSortable: true,
  },
  firstName: {
    field: 'FirstName',
  },
  age: { field: 'Age', type: 'number' },
};

@Component({
  selector: 'demo-root',
  imports: [DataSource, InfiniteTable],
  template: `
    <infinite-data-source [data]="data" primaryKey="Id">
      <infinite-table
        debugId="columnDefaultWidth-example"
        [columns]="columns"
        [columnDefaultWidth]="120"
      />
    </infinite-data-source>
  `,
})
export default class App {
  protected readonly data = data;
  protected readonly columns = columns;
}
```

### columnHeaderHeight (`number`)

> The height of the column header.

This only refers to the height of the header label - so if you have another row in the column header, for filters, the filters will also have this height. Also, for column groups, each additional group will have this height.

The column header height is set to `60` pixels. The column filters will also pick up this height.

```ts
import { Component } from '@angular/core';

import { DataSource, InfiniteTable } from '@infinite-table/infinite-angular';
import type {
  DataSourcePropFilterValue,
  InfiniteTableColumn,
} from '@infinite-table/infinite-angular';

import { data } from './data';
import type { Person } from './data';

const columns: Record<string, InfiniteTableColumn<Person>> = {
  identifier: {
    field: 'Id',
    type: 'number',
    defaultSortable: true,
  },
  firstName: {
    field: 'FirstName',
  },
  age: { field: 'Age', type: 'number' },
};

const defaultFilterValue: DataSourcePropFilterValue<Person> = [];

@Component({
  selector: 'demo-root',
  imports: [DataSource, InfiniteTable],
  template: `
    <infinite-data-source
      [data]="data"
      primaryKey="Id"
      [defaultFilterValue]="defaultFilterValue"
    >
      <infinite-table
        debugId="columnHeaderHeight-example"
        [columns]="columns"
        [columnHeaderHeight]="60"
      />
    </infinite-data-source>
  `,
})
export default class App {
  protected readonly data = data;
  protected readonly columns = columns;
  protected readonly defaultFilterValue = defaultFilterValue;
}
```

### columnMaxWidth (`number`)

> Specifies the maximum width for all columns.

For specifying the minimum column width, see [`columnMinWidth`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#columnMinWidth).

Maximum column width can be controlled more granularly via [`columnSizing.maxWidth`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#columnSizing.maxWidth), on a per column level.

```ts
import { Component } from '@angular/core';

import { DataSource, InfiniteTable } from '@infinite-table/infinite-angular';
import type {
  InfiniteTablePropColumnSizing,
  InfiniteTablePropColumns,
} from '@infinite-table/infinite-angular';

export const columns: InfiniteTablePropColumns<Employee> = {
  firstName: {
    field: 'firstName',
    header: 'First Name',
  },
  country: {
    field: 'country',
    header: 'Country',
  },
  city: {
    field: 'city',
    header: 'City',
  },
  salary: {
    field: 'salary',
    type: 'number',
    header: 'Salary',
  },
};

const defaultColumnSizing: InfiniteTablePropColumnSizing = {
  firstName: { flex: 1 },
  country: { flex: 1 },
  city: { flex: 1 },
  salary: { flex: 2 },
};

@Component({
  selector: 'demo-root',
  imports: [DataSource, InfiniteTable],
  template: `
    <infinite-data-source [data]="dataSource" primaryKey="id">
      <infinite-table
        debugId="columnMaxWidth-example"
        [columns]="columns"
        [columnMaxWidth]="200"
        [defaultColumnSizing]="defaultColumnSizing"
      />
    </infinite-data-source>
  `,
})
export default class App {
  protected readonly dataSource = dataSource;
  protected readonly columns = columns;
  protected readonly defaultColumnSizing = defaultColumnSizing;
}

const dataSource = () => {
  return fetch(process.env.NEXT_PUBLIC_BASE_URL + '/employees100')
    .then((r) => r.json())
    .then((data: Employee[]) => data);
};

export type Employee = {
  id: number;
  companyName: string;
  companySize: string;
  firstName: string;
  lastName: string;
  country: string;
  countryCode: string;
  city: string;
  streetName: string;
  streetNo: string;
  department: string;
  team: string;
  salary: number;
  age: number;
  email: string;
};
```

### columnMinWidth (`number`)

> Specifies the minimum width for all columns.

For specifying the maximum column width, see [`columnMaxWidth`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#columnMaxWidth).

Minimum column width can be controlled more granularly via [`columnSizing.minWidth`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#columnSizing.minWidth) or [`columns.minWidth`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#columns.minWidth), on a per column level.

```ts
import { Component } from '@angular/core';

import { DataSource, InfiniteTable } from '@infinite-table/infinite-angular';
import type {
  InfiniteTableColumn,
  InfiniteTablePropColumnSizing,
} from '@infinite-table/infinite-angular';

export const columns: Record<string, InfiniteTableColumn<Employee>> = {
  firstName: {
    field: 'firstName',
    header: 'First Name',
  },
  country: {
    field: 'country',
    header: 'Country',
  },
  city: {
    field: 'city',
    header: 'City',
  },
  salary: {
    field: 'salary',
    type: 'number',
    header: 'Salary',
  },
};

const defaultColumnSizing: InfiniteTablePropColumnSizing = {
  city: { flex: 1 },
  salary: { flex: 2 },
};

@Component({
  selector: 'demo-root',
  imports: [DataSource, InfiniteTable],
  template: `
    <infinite-data-source [data]="dataSource" primaryKey="id">
      <infinite-table
        debugId="columnMinWidth-example"
        [columns]="columns"
        [columnMinWidth]="300"
        [defaultColumnSizing]="defaultColumnSizing"
      />
    </infinite-data-source>
  `,
})
export default class App {
  protected readonly dataSource = dataSource;
  protected readonly columns = columns;
  protected readonly defaultColumnSizing = defaultColumnSizing;
}

const dataSource = () => {
  return fetch(process.env.NEXT_PUBLIC_BASE_URL + '/employees100')
    .then((r) => r.json())
    .then((data: Employee[]) => data);
};

export type Employee = {
  id: number;
  companyName: string;
  companySize: string;
  firstName: string;
  lastName: string;
  country: string;
  countryCode: string;
  city: string;
  streetName: string;
  streetNo: string;
  department: string;
  team: string;
  salary: number;
  age: number;
  email: string;
};
```

### columnOrder (`string[]|true`)

> Defines the order in which columns are displayed in the component

For uncontrolled usage, see [`defaultColumnOrder`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#defaultColumnOrder).

When using this controlled prop, make sure you also listen to [`(columnOrderChange)`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#onColumnOrderChange)

See [Column Order](https://infinite-table.com/angular/docs/learn/columns/column-order.md) for more details on ordering columns both programatically and via drag & drop.

The `columnOrder` array can contain identifiers that are not yet defined in the [`columns`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#columns) Map or can contain duplicate ids. This is a feature, not a bug. We want to allow you to use the `columnOrder` in a flexible way so it can define the order of current and future columns.

Displaying the same column twice is a perfectly valid use case.

**Example: Column order**

```ts
import { Component, signal } from '@angular/core';

import { DataSource, InfiniteTable } from '@infinite-table/infinite-angular';
import type { InfiniteTablePropColumns } from '@infinite-table/infinite-angular';

type Employee = {
  id: number;
  companyName: string;
  companySize: string;
  firstName: string;
  lastName: string;
  country: string;
  countryCode: string;
  city: string;
  streetName: string;
  streetNo: string;
  department: string;
  team: string;
  salary: number;
  age: number;
  email: string;
};

const columns: InfiniteTablePropColumns<Employee> = {
  firstName: {
    field: 'firstName',
    header: 'First Name',
  },
  country: {
    field: 'country',
    header: 'Country',
    columnGroup: 'location',
  },

  city: {
    field: 'city',
    header: 'City',
    columnGroup: 'address',
  },
  salary: {
    field: 'salary',
    type: 'number',
    header: 'Salary',
  },
  department: {
    field: 'department',
    header: 'Department',
  },
  team: {
    field: 'team',
    header: 'Team',
  },
  company: { field: 'companyName', header: 'Company' },

  companySize: {
    field: 'companySize',
    header: 'Company Size',
  },
};

const dataSource = () => {
  return fetch(process.env.NEXT_PUBLIC_BASE_URL + '/employees100')
    .then((r) => r.json())
    .then((data: Employee[]) => data);
};

@Component({
  selector: 'demo-root',
  imports: [DataSource, InfiniteTable],
  template: `
    <div style="color: var(--infinite-cell-color)">
      <p>
        Current column order:
        <code>
          <pre>{{ columnOrder().join(', ') }}.</pre>
        </code>
      </p>
      <p>Drag column headers to reorder.</p>
    </div>

    <infinite-data-source [data]="dataSource" primaryKey="id">
      <infinite-table
        debugId="columnOrder-example"
        [columns]="columns"
        [(columnOrder)]="columnOrder"
        [columnDefaultWidth]="200"
      />
    </infinite-data-source>
  `,
})
export default class App {
  protected readonly dataSource = dataSource;
  protected readonly columns = columns;

  
  protected readonly columnOrder = signal<string[]>([
    'firstName',
    'country',
    'team',
    'company',
    'department',
    'companySize',
  ]);
}
```

This prop can either be an array of strings (column ids) or the boolean `true`. When `true`, all columns present in the [`columns`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#columns) object will be displayed, in the iteration order of the object keys.

**Example: Column order advanced example**

```ts
import { Component, computed, signal } from '@angular/core';

import { DataSource, InfiniteTable } from '@infinite-table/infinite-angular';
import type { InfiniteTablePropColumns } from '@infinite-table/infinite-angular';

type Employee = {
  id: number;
  companyName: string;
  companySize: string;
  firstName: string;
  lastName: string;
  country: string;
  countryCode: string;
  city: string;
  streetName: string;
  streetNo: string;
  department: string;
  team: string;
  salary: number;
  age: number;
  email: string;
};

const columns: InfiniteTablePropColumns<Employee> = {
  firstName: {
    field: 'firstName',
    header: 'First Name',
  },
  country: {
    field: 'country',
    header: 'Country',
    columnGroup: 'location',
  },

  city: {
    field: 'city',
    header: 'City',
    columnGroup: 'address',
  },
  salary: {
    field: 'salary',
    type: 'number',
    header: 'Salary',
  },
  department: {
    field: 'department',
    header: 'Department',
  },
  team: {
    field: 'team',
    header: 'Team',
  },
  company: { field: 'companyName', header: 'Company' },

  companySize: {
    field: 'companySize',
    header: 'Company Size',
  },
};

const dataSource = () => {
  return fetch(process.env.NEXT_PUBLIC_BASE_URL + '/employees100')
    .then((r) => r.json())
    .then((data: Employee[]) => data);
};

@Component({
  selector: 'demo-root',
  imports: [DataSource, InfiniteTable],
  template: `
    <div style="color: var(--infinite-cell-color)">
      <p>
        Current column order:
        <code>
          <pre>{{ columnOrderJSON() }}.</pre>
        </code>
      </p>
      <p>
        Note: if the column order contains columns that don't exist in the
        \`columns\` definition, they will be skipped.
      </p>

      <button
        style="border: 2px solid currentColor; padding: 5px"
        (click)="columnOrder.set(['firstName', 'country'])"
      >
        Click to only show "firstName" and "country".
      </button>

      <button
        style="border: 2px solid currentColor; padding: 5px; margin-left: 5px"
        (click)="columnOrder.set(true)"
      >
        Click to reset column order.
      </button>
    </div>

    <infinite-data-source [data]="dataSource" primaryKey="id">
      <infinite-table
        debugId="columnOrder-advanced-example"
        [columns]="columns"
        [(columnOrder)]="columnOrder"
        [columnDefaultWidth]="200"
      />
    </infinite-data-source>
  `,
})
export default class App {
  protected readonly dataSource = dataSource;
  protected readonly columns = columns;

  protected readonly columnOrder = signal<string[] | true>([
    'firstName',
    'country',
    'team',
    'company',
    'firstName',
    'not existing column',
    'companySize',
  ]);

  protected readonly columnOrderJSON = computed(() =>
    JSON.stringify(this.columnOrder()),
  );
}
```

Using [`[(columnOrder)]`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#columnOrder) in combination with [`[(columnVisibility)]`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#columnVisibility) is very powerful - for example, you can have a specific column order even for columns which are not visible at a certain moment, so when they will be made visible, you'll know exactly where they will be displayed.

### columns (`Record<string, InfiniteTableColumn<DATA_TYPE>>`)

> Describes the columns available in the component.

The following properties are available:

- [field](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#columns.field)
- [defaultWidth](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#columns.defaultWidth)
- [defaultFlex](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#columns.defaultFlex)
- [render](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#columns.render)
- [renderValue](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#columns.renderValue)
- [type](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#columns.type)
- [header](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#columns.header)
- [valueGetter](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#columns.valueGetter)
- [valueFormatter](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#columns.valueFormatter)
- ...etc

```ts
import { Component } from '@angular/core';

import { DataSource, InfiniteTable } from '@infinite-table/infinite-angular';
import type { InfiniteTablePropColumns } from '@infinite-table/infinite-angular';

import { data } from './data';
import type { Person } from './data';

const columns: InfiniteTablePropColumns<Person> = {
  identifier: {
    field: 'Id',
    type: 'number',
    defaultSortable: true,
    defaultWidth: 80,
  },
  firstName: {
    field: 'FirstName',
  },
  age: { field: 'Age', type: 'number' },
};

@Component({
  selector: 'demo-root',
  imports: [DataSource, InfiniteTable],
  template: `
    <infinite-data-source [data]="data" primaryKey="Id">
      <infinite-table debugId="columns-example" [columns]="columns" />
    </infinite-data-source>
  `,
})
export default class App {
  protected readonly data = data;
  protected readonly columns = columns;
}
```

### columns.className (`string | (param: InfiniteTableColumnStyleFnParams) => string`)

> Controls styling via CSS classes for the column. Can be a `string` or a function returning a `string` (a valid className).

If defined as a function, it accepts an object as a parameter (of type [`InfiniteTableColumnStylingFnParams`](https://infinite-table.com/docs/reference/type-definitions/index.md#InfiniteTableColumnStylingFnParams)), which has the following properties:

- `column` - the current column where the className is being applied
- `data` - the data object for the current row. The type of this object is `DATA_TYPE | Partial<DATA_TYPE> | null`. For regular rows, it will be of type `DATA_TYPE`, while for group rows it will be `Partial<DATA_TYPE>`. For rows not yet loaded (because of batching being used), it will be `null`.
- `rowInfo` - the information about the current row - see [Using RowInfo](https://infinite-table.com/angular/docs/learn/rows/using-row-info.md) for more details.
- `value` - the underlying value of the current cell - will generally be `data[column.field]`, if the column is bound to a `field` property
- ... and more, see [`InfiniteTableColumnStylingFnParams`](https://infinite-table.com/docs/reference/type-definitions/index.md#InfiniteTableColumnStylingFnParams) for details

The `className` property can also be specified for [`columnTypes`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#columnTypes)

```ts
import { Component, ViewEncapsulation } from '@angular/core';

import { DataSource, InfiniteTable } from '@infinite-table/infinite-angular';
import type { InfiniteTablePropColumns } from '@infinite-table/infinite-angular';

type Developer = {
  id: number;
  firstName: string;
  lastName: string;
  country: string;
  city: string;
  currency: string;
  preferredLanguage: string;
  stack: string;
  canDesign: 'yes' | 'no';
  hobby: string;
  salary: number;
  age: number;
};

const dataSource = () => {
  return fetch(process.env.NEXT_PUBLIC_BASE_URL + '/developers1k')
    .then((r) => r.json())
    .then((data: Developer[]) => data);
};

const columns: InfiniteTablePropColumns<Developer> = {
  id: {
    field: 'id',
    defaultWidth: 80,
  },
  firstName: { field: 'firstName' },

  salary: {
    field: 'salary',
    type: 'number',
    className: ({ value }) => {
      return value && value > 100_000 ? 'red-color' : 'tomato-color';
    },
  },
  preferredLanguage: { field: 'preferredLanguage' },
  stack: { field: 'stack' },
  country: { field: 'country' },
  age: { field: 'age', type: 'number' },

  currency: { field: 'currency', type: 'number' },
};

@Component({
  selector: 'demo-root',
  imports: [DataSource, InfiniteTable],
  // the cells are rendered by the grid, not by this template:
  // the classes need global styles
  encapsulation: ViewEncapsulation.None,
  styles: `
    .red-color {
      color: red;
    }
    .tomato-color {
      color: tomato;
    }
  `,
  template: `
    <infinite-data-source primaryKey="id" [data]="dataSource">
      <infinite-table
        debugId="column-className-function-example"
        [columns]="columns"
        [columnDefaultWidth]="200"
      />
    </infinite-data-source>
  `,
})
export default class App {
  protected readonly dataSource = dataSource;
  protected readonly columns = columns;
}
```

### components

> Components to override the default ones used by the DataGrid.

The following components can be overridden:

- `LoadMask` - see [`components.LoadMask`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#components.LoadMask)
- `CheckBox` - see [`components.CheckBox`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#components.CheckBox)
- `Menu`
- `MenuIcon`

### components.LoadMask

> Allows customising the `LoadMask` displayed over the DataGrid when it's loading data.

To better test this out, you can use the controlled [`[(loading)]`](https://infinite-table.com/angular/docs/reference/datasource-props/index.md#loading) prop on the `<DataSource />`

For more components that can be overriden, see [`components`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#components)

**Example: Custom LoadMask component**

```ts
import { Component, input } from '@angular/core';

import { DataSource, InfiniteTable } from '@infinite-table/infinite-angular';
import type {
  InfiniteTableColumn,
  Renderable,
} from '@infinite-table/infinite-angular';

// the components.LoadMask override gets the same inputs as the default one
@Component({
  selector: 'custom-load-mask',
  host: {
    style:
      'width: 100%; height: 100%; z-index: 100; background: tomato; opacity: 0.3; display: flex; align-items: center; justify-content: center',
  },
  template: `
    <div
      style="padding: 20px; background: white; color: black; border-radius: 5px"
    >
      Loading App ...
    </div>
  `,
})
class LoadMask {
  readonly visible = input<boolean>(false);
  readonly loadingText = input<Renderable>();
}

type Employee = {
  id: string | number;
  name: string;
  salary: number;
  department: string;
  company: string;
};

const employees: Employee[] = [
  {
    id: 1,
    name: 'Bob',
    salary: 10_000,
    department: 'IT',
    company: 'Bobsons',
  },
  {
    id: 2,
    name: 'Alice',
    salary: 20_000,
    department: 'IT',
    company: 'Bobsons',
  },
];

const columns: Record<string, InfiniteTableColumn<Employee>> = {
  id: {
    field: 'id',
    type: 'number',
    defaultWidth: 80,
  },
  name: {
    field: 'name',
  },
  salary: { field: 'salary', type: 'number' },
  department: { field: 'department', header: 'Dep.' },
  company: { field: 'company' },
};

@Component({
  selector: 'demo-root',
  imports: [DataSource, InfiniteTable],
  template: `
    <infinite-data-source [loading]="true" [data]="employees" primaryKey="id">
      <infinite-table
        debugId="load-mask-example"
        [components]="components"
        [columnDefaultWidth]="130"
        [columns]="columns"
      />
    </infinite-data-source>
  `,
})
export default class App {
  protected readonly employees = employees;
  protected readonly columns = columns;
  protected readonly components = { LoadMask };
}
```

### components.CheckBox

> Allows customising the checkbox rendered by the DataGrid.

The custom component is used for:

- the row selection checkboxes in column cells and the select-all checkbox in column headers
- the checkboxes in the `Columns` and `Group by` submenus of the default column menu

The component receives the following props:

- `checked` - `true`, `false` or `null` (for indeterminate)
- `disabled` - `boolean`
- `onChange(checked)` - call it with the new checked value when the user toggles the checkbox
- `domProps` - DOM props to spread on the root element

For more components that can be overriden, see [`components`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#components)

### columns.renderTreeIcon (`boolean|(cellContext) => ReactNode`)

> Renders the tree expand/collapse icon in the column cells. If you want default behavior, specify `true` and the default icon will be used.

To render a custom icon, specify a function that returns a React node. The `cellContext` object param will contain all the information about the current cell.

The `cellContext` object contains a `toggleCurrentTreeNode` function property, which can be used to toggle the node state when clicked.

With the default value of `true`, an icon will be rendered only for parent nodes. If you want to render an icon for all nodes, specify a function (and differentiate between parent and leaf nodes), and it will be called regardless of whether the node is a parent or a leaf.

You can also use [`columns.renderTreeIconForParentNode`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#columns.renderTreeIconForParentNode) to specify to customize the tree icon rendering for parent nodes or [`columns.renderTreeIconForLeafNode`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#columns.renderTreeIconForLeafNode) to customize the tree icon rendering for leaf nodes.

**Example: Specifying a column to used as the tree icon**

```ts
import { Component, computed, signal } from '@angular/core';

import { TreeDataSource, TreeGrid } from '@infinite-table/infinite-angular';
import type { InfiniteTableColumn } from '@infinite-table/infinite-angular';

type FileSystemNode = {
  id: string;
  name: string;
  type: 'folder' | 'file';
  extension?: string;
  mimeType?: string;
  sizeInKB: number;
  children?: FileSystemNode[];
};

const allColumns: Record<string, InfiniteTableColumn<FileSystemNode>> = {
  name: { field: 'name', header: 'Name' },
  type: { field: 'type', header: 'Type' },
  extension: { field: 'extension', header: 'Extension' },
  mimeType: { field: 'mimeType', header: 'Mime Type' },
  size: { field: 'sizeInKB', type: 'number', header: 'Size (KB)' },
};

const dataSource = () => {
  const nodes: FileSystemNode[] = [
    {
      id: '1',
      name: 'Documents',
      sizeInKB: 1200,
      type: 'folder',
      children: [
        {
          id: '10',
          name: 'Private',
          sizeInKB: 100,
          type: 'folder',
          children: [
            {
              id: '100',
              name: 'Report.docx',
              sizeInKB: 210,
              type: 'file',
              extension: 'docx',
              mimeType: 'application/msword',
            },
            {
              id: '101',
              name: 'Vacation.docx',
              sizeInKB: 120,
              type: 'file',
              extension: 'docx',
              mimeType: 'application/msword',
            },
            {
              id: '102',
              name: 'CV.pdf',
              sizeInKB: 108,
              type: 'file',
              extension: 'pdf',
              mimeType: 'application/pdf',
            },
          ],
        },
      ],
    },
    {
      id: '2',
      name: 'Desktop',
      sizeInKB: 1000,
      type: 'folder',
      children: [],
    },
    {
      id: '3',
      name: 'Media',
      sizeInKB: 1000,
      type: 'folder',
      children: [
        {
          id: '30',
          name: 'Music',
          sizeInKB: 0,
          type: 'folder',
          children: [],
        },
        {
          id: '31',
          name: 'Videos',
          sizeInKB: 5400,
          type: 'folder',
          children: [
            {
              id: '310',
              name: 'Vacation.mp4',
              sizeInKB: 108,
              type: 'file',
              extension: 'mp4',
              mimeType: 'video/mp4',
            },
          ],
        },
      ],
    },
  ];
  return Promise.resolve(nodes);
};

@Component({
  selector: 'demo-root',
  imports: [TreeDataSource, TreeGrid],
  template: `
    <infinite-tree-data-source
      nodesKey="children"
      primaryKey="id"
      [data]="dataSource"
    >
      <div style="color: var(--infinite-cell-color); padding: 10px">
        <p>Select the tree column</p>
        <select
          (change)="onTreeIconChange($event)"
          title="Select column to use for the tree icon"
        >
          @for (key of columnKeys; track key) {
            <option [value]="key" [selected]="key === treeIcon()">
              {{ key }}
            </option>
          }
          <option value="none" [selected]="treeIcon() === 'none'">
            No tree column
          </option>
        </select>
      </div>

      <infinite-tree-grid [columns]="columns()" />
    </infinite-tree-data-source>
  `,
})
export default class App {
  protected readonly dataSource = dataSource;
  protected readonly columnKeys = Object.keys(allColumns);

  protected readonly treeIcon = signal<string>('name');

  protected readonly columns = computed(() => {
    const cols = { ...allColumns };
    const treeIcon = this.treeIcon();

    
    cols[treeIcon] = {
      ...cols[treeIcon],
      renderTreeIcon: true,
    };

    return cols;
  });

  protected onTreeIconChange(event: Event) {
    this.treeIcon.set((event.target as HTMLSelectElement).value);
  }
}
```

This example renders a custom tree icon and uses the `toggleCurrentTreeNode` function to toggle the node state when Clicked. `toggleCurrentTreeNode` is a property of the `cellContext` argument passed to the `renderTreeIcon` function.

**Example: Rendering a custom tree icon for both parent and leaf nodes**

```ts
import { Component, TemplateRef, viewChild } from '@angular/core';

import { TreeDataSource, TreeGrid } from '@infinite-table/infinite-angular';
import type { InfiniteTableColumn } from '@infinite-table/infinite-angular';

type FileSystemNode = {
  id: string;
  name: string;
  type: 'folder' | 'file';
  extension?: string;
  sizeInKB: number;
  children?: FileSystemNode[];
};

const dataSource = () => {
  const nodes: FileSystemNode[] = [
    {
      id: '1',
      name: 'Documents',
      sizeInKB: 1200,
      type: 'folder',
      children: [
        {
          id: '10',
          name: 'Private',
          sizeInKB: 100,
          type: 'folder',
          children: [
            {
              id: '100',
              name: 'Report.docx',
              sizeInKB: 210,
              type: 'file',
              extension: 'docx',
            },
            {
              id: '101',
              name: 'Vacation.docx',
              sizeInKB: 120,
              type: 'file',
              extension: 'docx',
            },
            {
              id: '102',
              name: 'CV.pdf',
              sizeInKB: 108,
              type: 'file',
              extension: 'pdf',
            },
          ],
        },
      ],
    },
    {
      id: '2',
      name: 'Desktop',
      sizeInKB: 1000,
      type: 'folder',
      children: [
        {
          id: '20',
          name: 'unknown.txt',
          sizeInKB: 100,
          type: 'file',
          extension: 'txt',
        },
      ],
    },
    {
      id: '3',
      name: 'Media',
      sizeInKB: 1000,
      type: 'folder',
      children: [
        {
          id: '30',
          name: 'Music - empty',
          sizeInKB: 0,
          type: 'folder',
          children: [],
        },
        {
          id: '31',
          name: 'Videos',
          sizeInKB: 5400,
          type: 'folder',
          children: [
            {
              id: '310',
              name: 'Vacation.mp4',
              sizeInKB: 108,
              type: 'file',
              extension: 'mp4',
            },
          ],
        },
      ],
    },
  ];
  return Promise.resolve(nodes);
};

@Component({
  selector: 'demo-root',
  imports: [TreeDataSource, TreeGrid],
  styles: `
    svg {
      vertical-align: middle;
      position: relative;
      top: -1px;
      margin-inline: 5px;
    }
  `,
  template: `
    <infinite-tree-data-source
      nodesKey="children"
      primaryKey="id"
      [data]="dataSource"
    >
      <infinite-tree-grid [columns]="columns" />
    </infinite-tree-data-source>

    
    <ng-template
      #treeIcon
      let-rowInfo="rowInfo"
      let-toggleCurrentTreeNode="toggleCurrentTreeNode"
    >
      @if (rowInfo.isParentNode) {
        <svg
          xmlns="http://www.w3.org/2000/svg"
          height="20px"
          viewBox="0 -960 960 960"
          width="20px"
          fill="currentColor"
          style="cursor: pointer"
          (click)="toggleCurrentTreeNode()"
        >
          @if (rowInfo.nodeExpanded) {
            <path
              d="M160-160q-33 0-56.5-23.5T80-240v-480q0-33 23.5-56.5T160-800h240l80 80h320q33 0 56.5 23.5T880-640H447l-80-80H160v480l96-320h684L837-217q-8 26-29.5 41.5T760-160H160Zm84-80h516l72-240H316l-72 240Zm0 0 72-240-72 240Zm-84-400v-80 80Z"
            />
          } @else {
            <path
              d="M160-160q-33 0-56.5-23.5T80-240v-480q0-33 23.5-56.5T160-800h240l80 80h320q33 0 56.5 23.5T880-640v400q0 33-23.5 56.5T800-160H160Zm0-80h640v-400H447l-80-80H160v480Zm0 0v-480 480Z"
            />
          }
        </svg>
      } @else {
        <svg
          xmlns="http://www.w3.org/2000/svg"
          height="20px"
          viewBox="0 -960 960 960"
          width="20px"
          fill="currentColor"
        >
          <path
            d="M240-80q-33 0-56.5-23.5T160-160v-640q0-33 23.5-56.5T240-880h320l240 240v480q0 33-23.5 56.5T720-80H240Zm280-520v-200H240v640h480v-440H520ZM240-800v200-200 640-640Z"
          />
        </svg>
      }
    </ng-template>
  `,
})
export default class App {
  protected readonly dataSource = dataSource;

  private readonly treeIcon =
    viewChild.required<TemplateRef<unknown>>('treeIcon');

  protected readonly columns: Record<
    string,
    InfiniteTableColumn<FileSystemNode>
  > = {
    // the template gets the render params (rowInfo, toggleCurrentTreeNode, ...)
    name: {
      renderTreeIcon: () => this.treeIcon(),
      field: 'name',
      header: 'Name',
    },
    type: { field: 'type', header: 'Type' },
    extension: { field: 'extension', header: 'Extension' },
    size: { field: 'sizeInKB', type: 'number', header: 'Size (KB)' },
  };
}
```

### columns.renderRowDetailIcon (`boolean|(cellContext) => ReactNode`)

> Renders the row detail expand/collapse icon in the column cell. Only used when [master-detail](https://infinite-table.com/angular/docs/learn/master-detail/overview.md) is enabled.

If this function is a prop, it can be used to customize the icon rendered for expanding/collapsing the row detail.

See related [`rowDetailRenderer`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#rowDetailRenderer) for configuring master-detail.

This example shows a master DataGrid with the ID column configured to show the row detail expand icon.

**Example: Basic master detail DataGrid example**

```ts
import { Component, TemplateRef, viewChild } from '@angular/core';

import { DataSource, InfiniteTable } from '@infinite-table/infinite-angular';
import type {
  DataSourceData,
  InfiniteTablePropColumns,
  InfiniteTableRowInfo,
} from '@infinite-table/infinite-angular';

type Developer = {
  id: number;
  firstName: string;
  lastName: string;

  city: string;
  currency: string;
  country: string;
  preferredLanguage: string;
  stack: string;
  canDesign: 'yes' | 'no';

  salary: number;
};

type City = {
  id: number;
  name: string;
  country: string;
};

const masterColumns: InfiniteTablePropColumns<City> = {
  id: {
    field: 'id',
    header: 'ID',
    defaultWidth: 70,
    renderRowDetailIcon: true,
  },
  country: { field: 'country', header: 'Country' },
  city: { field: 'name', header: 'City', defaultFlex: 1 },
};

const detailColumns: InfiniteTablePropColumns<Developer> = {
  firstName: {
    field: 'firstName',
    header: 'First Name',
  },
  salary: {
    field: 'salary',
    type: 'number',
  },

  stack: { field: 'stack' },
  currency: { field: 'currency' },
  city: { field: 'city' },
};

const domProps = {
  style: {
    height: '100%',
  },
};
const shouldReloadData = {
  sortInfo: true,
  filterValue: true,
};

// fetch an array of cities from the server
const citiesDataSource: DataSourceData<City> = () => {
  const cityNames = new Set<string>();
  const result: City[] = [];
  return fetch(process.env.NEXT_PUBLIC_BASE_URL + `/developers1k-sql`)
    .then((response) => response.json())
    .then((response) => {
      response.data.forEach((data: Developer) => {
        if (cityNames.has(data.city)) {
          return;
        }
        cityNames.add(data.city);
        result.push({
          name: data.city,
          country: data.country,
          id: result.length,
        });
      });

      return result;
    });
};

const detailDataSource: DataSourceData<Developer> = ({
  filterValue,
  sortInfo,
  masterRowInfo,
}) => {
  if (sortInfo && !Array.isArray(sortInfo)) {
    sortInfo = [sortInfo];
  }

  if (!filterValue) {
    filterValue = [];
  }
  if (masterRowInfo) {
    // filter by master country and city
    filterValue = [
      {
        field: 'city',
        filter: {
          operator: 'eq',
          type: 'string',
          value: masterRowInfo.data.name,
        },
      },
      {
        field: 'country',
        filter: {
          operator: 'eq',
          type: 'string',
          value: masterRowInfo.data.country,
        },
      },
      ...filterValue,
    ];
  }
  const args = [
    sortInfo
      ? 'sortInfo=' +
        JSON.stringify(
          sortInfo.map((s) => ({
            field: s.field,
            dir: s.dir,
          })),
        )
      : null,

    filterValue
      ? 'filterBy=' +
        JSON.stringify(
          filterValue.map(({ field, filter }) => {
            return {
              field: field,
              operator: filter.operator,
              value:
                filter.type === 'number' ? Number(filter.value) : filter.value,
            };
          }),
        )
      : null,
  ]
    .filter(Boolean)
    .join('&');

  return fetch(process.env.NEXT_PUBLIC_BASE_URL + `/developers1k-sql?` + args)
    .then((r) => r.json())
    .then((data: Developer[]) => data);
};

@Component({
  selector: 'demo-root',
  imports: [DataSource, InfiniteTable],
  template: `
    <infinite-data-source
      [data]="citiesDataSource"
      primaryKey="id"
      [defaultSortInfo]="[
        {
          field: 'country',
          dir: 1,
        },
        {
          field: 'name',
          dir: 1,
        },
      ]"
    >
      <infinite-table
        debugId="master-detail-example-2"
        [domProps]="domProps"
        [columnDefaultWidth]="150"
        [columnMinWidth]="50"
        [columns]="masterColumns"
        [rowDetailRenderer]="renderDetail"
      />
    </infinite-data-source>

    
    <ng-template #detail>
      <infinite-data-source
        [data]="detailDataSource"
        primaryKey="id"
        [shouldReloadData]="shouldReloadData"
      >
        <infinite-table
          debugId="master-detail-example"
          [columnDefaultWidth]="150"
          [columnMinWidth]="50"
          [columns]="detailColumns"
        />
      </infinite-data-source>
    </ng-template>
  `,
})
export default class App {
  protected readonly citiesDataSource = citiesDataSource;
  protected readonly detailDataSource = detailDataSource;
  protected readonly masterColumns = masterColumns;
  protected readonly detailColumns = detailColumns;
  protected readonly domProps = domProps;
  protected readonly shouldReloadData = shouldReloadData;

  private readonly detailTemplate =
    viewChild.required<TemplateRef<unknown>>('detail');

  // a field, so the grid gets the same function every time
  protected readonly renderDetail = (rowInfo: InfiniteTableRowInfo<City>) => {
    console.log('rendering detail for master row', rowInfo.id);
    return this.detailTemplate();
  };
}
```

### columns.components

> Specifies custom components to use for column cells or header

The column components object can have either of the two following properties:

- [ColumnCell](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#columns.components.ColumnCell) - a component to use for rendering the column cells
- [HeaderCell](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#columns.components.HeaderCell) - a component to use for rendering the column header

- [Editor](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#columns.components.Editor) - a component to use for the editor, when editing is enabled for the column

- [FilterOperatorSwitch](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#columns.components.FilterOperatorSwitch) - a component to use for the filter operator switch - clicking the operator pops up a menu with the available operators for that column filter.

See [editing docs](https://infinite-table.com/angular/docs/learn/editing/overview.md).

### columns.components.ColumnCell

> Specifies a custom component to use for column cells

For column header see related [`columns.components.HeaderCell`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#columns.components.HeaderCell).

Inside a component used as a cell, you have to use [`injectColumnCell`](https://infinite-table.com/docs/reference/hooks/index.md#useInfiniteColumnCell) to retrieve information about the currently rendered cell.

A cell component is an Angular component whose host element is the cell itself: give it an attribute selector on a `div`. The grid adds its cell directive to that element, so the class names, styles and attributes of the cell go on your host element - there is no `domRef` to pass on and no props to spread.

```ts
// an attribute selector on a div: the host element of the component is the
// root DOM element of the cell
selector: 'div[myColumnCell]',
```

It reads the cell (value, rowInfo, column...) with [`injectColumnCell`](https://infinite-table.com/docs/reference/hooks/index.md#useInfiniteColumnCell), as a signal:

```ts
// the cell (value, rowInfo, column, ...), as a signal
protected readonly cell = injectColumnCell<DATA_TYPE>();
```

To render the default content of the cell, use `injectColumnCellChildren()` with the `InfiniteRender` outlet:

```ts
@Component({
  selector: 'div[customCell]',
  imports: [InfiniteRender],
  // the default content of the cell
  template: `<ng-container [infiniteRender]="children()" />`,
})
class CustomComponent {
  protected readonly children = injectColumnCellChildren();
}
```

Your own class names, styles and content go around it:

```ts
@Component({
  selector: 'div[exampleCell]',
  imports: [InfiniteRender],
  host: { class: 'extra-cls', '[style]': 'style' },
  template: `<ng-container [infiniteRender]="children()" />
    <div style="flex: 1"></div>
    {{ emoji }}`,
})
class ExampleCellComponent {
  protected readonly children = injectColumnCellChildren();

  protected readonly style = style;
  protected readonly emoji = emoji;
}
```

**Example: Custom components**

```ts
import { Component, computed } from '@angular/core';

import {
  DataSource,
  InfiniteRender,
  InfiniteTable,
  injectColumnCell,
  injectColumnCellChildren,
  injectHeaderCell,
} from '@infinite-table/infinite-angular';
import type {
  InfiniteTablePropColumns,
  InfiniteTablePropColumnTypes,
} from '@infinite-table/infinite-angular';

type Developer = {
  id: number;
  firstName: string;
  lastName: string;
  country: string;
  city: string;
  currency: string;
  preferredLanguage: string;
  stack: string;
  canDesign: 'yes' | 'no';
  hobby: string;
  salary: number;
  age: number;
};

const dataSource = () => {
  return fetch(process.env.NEXT_PUBLIC_BASE_URL + '/developers1k')
    .then((r) => r.json())
    .then((data: Developer[]) => data);
};

// the host element of the component is the header cell
@Component({
  selector: 'div[defaultHeaderComponent]',
  host: { style: 'border: 1px solid #fefefe' },
  // here you would usually render the default children
  // (`injectHeaderCellChildren()`) and the sort tool, but in this case we
  // want to override the default sort tool as well (which is part of the
  // default children)
  template: `{{ headerCell().column.field }} {{ sortTool() }}`,
})
class DefaultHeaderComponent {
  protected readonly headerCell = injectHeaderCell<Developer>();

  protected readonly sortTool = computed(() => {
    switch (this.headerCell().columnSortInfo?.dir) {
      case undefined:
        return '👉';
      case 1:
        return '👇';
      case -1:
        return '☝🏽';
    }
    return '';
  });
}

// the host element of the component is the cell
@Component({
  selector: 'div[stackComponent]',
  imports: [InfiniteRender],
  host: { '[style]': 'style()' },
  template: `<ng-container [infiniteRender]="children()" />
    <div style="flex: 1"></div>
    {{ emoji() }}`,
})
class StackComponent {
  private readonly cell = injectColumnCell<Developer>();
  // the default content of the cell
  protected readonly children = injectColumnCellChildren();

  private readonly isFrontEnd = computed(
    () => this.cell().value === 'frontend',
  );

  protected readonly emoji = computed(() => (this.isFrontEnd() ? '⚛️' : '💽'));

  protected readonly style = computed(() => ({
    padding: '5px 20px',
    border: `1px solid ${this.isFrontEnd() ? 'red' : 'green'}`,
  }));
}

const columnTypes: InfiniteTablePropColumnTypes<Developer> = {
  default: {
    // override all columns to use these components
    components: {
      HeaderCell: DefaultHeaderComponent,
    },
  },
};

const columns: InfiniteTablePropColumns<Developer> = {
  id: { field: 'id', defaultWidth: 80 },
  stack: {
    field: 'stack',
    renderValue: ({ data }) => 'Stack: ' + data?.stack,
    components: {
      HeaderCell: DefaultHeaderComponent,
      ColumnCell: StackComponent,
    },
  },
  firstName: {
    field: 'firstName',
  },
  preferredLanguage: {
    field: 'preferredLanguage',
  },
};

@Component({
  selector: 'demo-root',
  imports: [DataSource, InfiniteTable],
  template: `
    <infinite-data-source primaryKey="id" [data]="dataSource">
      <infinite-table
        debugId="column-components-example"
        [columns]="columns"
        [columnTypes]="columnTypes"
      />
    </infinite-data-source>
  `,
})
export default class App {
  protected readonly dataSource = dataSource;
  protected readonly columns = columns;
  protected readonly columnTypes = columnTypes;
}
```

### columns.components.Editor

> Specifies a custom component to use for the editor, when [editing](https://infinite-table.com/angular/docs/learn/editing/overview.md) is enabled for the column.

The editor component calls [`injectColumnEditor`](https://infinite-table.com/docs/reference/hooks/index.md#useInfiniteColumnEditor) to read the cell being edited (the value, the initial value, whether it is read-only) and to confirm, cancel or reject the edit. A TemplateRef works as an editor too: mark its input with `infiniteEditorInput`.

Here's the implementation for our default editor

```ts
@Component({
  selector: 'input[myColumnEditor]',
  host: {
    type: 'text',
    '[readOnly]': 'editor.readOnly()',
    '(input)': 'onInput()',
    '(keydown)': 'onKeyDown($event)',
    '(blur)': 'onBlur()',
  },
  template: '',
})
export class InfiniteTableColumnEditor implements AfterViewInit {
  protected readonly editor = injectColumnEditor();

  private readonly input =
    inject<ElementRef<HTMLInputElement>>(ElementRef).nativeElement;

  constructor() {
    this.input.value = this.editor.initialValue ?? '';
  }

  ngAfterViewInit() {
    this.input.focus();
  }

  protected onInput() {
    this.editor.setValue(this.input.value);
  }

  protected onKeyDown(event: KeyboardEvent) {
    const { key } = event;
    if (key === 'Enter' || key === 'Tab') {
      this.editor.confirmEdit();
      // the grid would start a new edit on this key
      event.stopPropagation();
      if (key === 'Tab') {
        event.preventDefault();
      }
    } else if (key === 'Escape') {
      this.editor.cancelEdit();
    } else {
      event.stopPropagation();
    }
  }

  protected onBlur() {
    // not after Enter or Escape, which already ended the edit
    if (this.editor.api.isEditInProgress()) {
      this.editor.confirmEdit();
    }
  }
}
```

Try editing the `salary` column - it has a custom editor

**Example: Column with custom editor**

```ts
import { Component, ElementRef, viewChild } from '@angular/core';
import type { AfterViewInit } from '@angular/core';

import {
  DataSource,
  InfiniteTable,
  injectColumnEditor,
} from '@infinite-table/infinite-angular';
import type { InfiniteTablePropColumns } from '@infinite-table/infinite-angular';

type Developer = {
  id: number;
  firstName: string;
  currency: string;
  stack: string;
  hobby: string;
  salary: string;
};
const dataSource: Developer[] = [
  {
    id: 1,
    firstName: 'John',
    currency: 'USD',
    stack: 'frontend',
    hobby: 'gaming',
    salary: 'USD 1000',
  },
  {
    id: 2,
    firstName: 'Jane',
    currency: 'EUR',
    stack: 'backend',
    hobby: 'reading',
    salary: 'EUR 2000',
  },
  {
    id: 3,
    firstName: 'Jack',
    currency: 'GBP',
    stack: 'frontend',
    hobby: 'gaming',
    salary: 'GBP 3000',
  },
  {
    id: 4,
    firstName: 'Jill',
    currency: 'USD',
    stack: 'backend',
    hobby: 'reading',
    salary: 'USD 4000',
  },
];

@Component({
  selector: 'custom-editor',
  template: `
    <div
      style="background: #ad1; padding: 5px; width: 100%; height: 100%; position: absolute; left: 0; top: 0"
    >
      <input
        #input
        style="width: 100%; height: 100%"
        [value]="editor.initialValue"
        (keydown)="onKeydown($event)"
      />
    </div>
  `,
})
class CustomEditor implements AfterViewInit {
  protected readonly editor = injectColumnEditor();

  private readonly input =
    viewChild.required<ElementRef<HTMLInputElement>>('input');

  ngAfterViewInit() {
    this.input().nativeElement.focus();
  }

  protected onKeydown(event: KeyboardEvent) {
    const { key } = event;
    if (key === 'Enter' || key === 'Tab') {
      this.editor.confirmEdit(this.input().nativeElement.value);
    } else if (key === 'Escape') {
      this.editor.cancelEdit();
    } else {
      event.stopPropagation();
    }
  }
}

const columns: InfiniteTablePropColumns<Developer> = {
  id: { field: 'id', defaultWidth: 80, defaultEditable: false },

  salary: {
    components: {
      // reference to the custom editor component
      Editor: CustomEditor,
    },

    defaultWidth: 320,
    field: 'salary',
    header: 'Salary - edit accepts numbers only',
    style: { color: 'tomato' },
    getValueToEdit: ({ value }) => {
      return parseInt(value.substr(4), 10);
    },
    getValueToPersist: ({ value, data }) => {
      return `${data!.currency} ${parseInt(value, 10)}`;
    },
    shouldAcceptEdit: ({ value }) => {
      return parseInt(value, 10) == value;
    },
  },

  firstName: {
    field: 'firstName',
    header: 'Name',
  },
  currency: {
    field: 'currency',
    header: 'Currency',
  },
};

@Component({
  selector: 'demo-root',
  imports: [DataSource, InfiniteTable],
  template: `
    <infinite-data-source primaryKey="id" [data]="dataSource">
      <infinite-table
        debugId="custom-editor-hooks-example"
        [columns]="columns"
        [columnDefaultEditable]="true"
      />
    </infinite-data-source>
  `,
})
export default class App {
  protected readonly dataSource = dataSource;
  protected readonly columns = columns;
}
```

### columns.components.HeaderCell

> Specifies a custom component to use for column headers

For column cells see related [`columns.components.ColumnCell`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#columns.components.ColumnCell).

Inside a custom component used as a column header, you have to use [`injectHeaderCell`](https://infinite-table.com/docs/reference/hooks/index.md#useInfiniteHeaderCell) to retrieve information about the currently rendered header cell.

A header cell component is an Angular component whose host element is the header cell itself: give it an attribute selector on a `div`. The grid adds its header cell directive to that element, so the class names, styles and attributes of the header cell go on your host element - there is no `domRef` to pass on and no props to spread.

```ts
// an attribute selector on a div: the host element of the component is the
// root DOM element of the header cell
selector: 'div[myHeaderCell]',
```

It reads the header cell (column, columnApi, sort and filter info...) with [`injectHeaderCell`](https://infinite-table.com/docs/reference/hooks/index.md#useInfiniteHeaderCell), as a signal:

```ts
// the header cell (column, columnApi, sort and filter info, ...), as a signal
protected readonly headerCell = injectHeaderCell<DATA_TYPE>();
```

To render the default content of the header cell, use `injectHeaderCellChildren()` with the `InfiniteRender` outlet:

```ts
@Component({
  selector: 'div[customHeaderCell]',
  imports: [InfiniteRender],
  // the default content of the header cell
  template: `<ng-container [infiniteRender]="children()" />`,
})
class CustomHeaderComponent {
  protected readonly children = injectHeaderCellChildren();
}
```

Your own class names, styles and content go around it:

```ts
@Component({
  selector: 'div[exampleHeaderCell]',
  imports: [InfiniteRender],
  host: { class: 'extra-cls', '[style]': 'style' },
  template: `<ng-container [infiniteRender]="children()" />
    <div style="flex: 1"></div>
    {{ emoji }}`,
})
class ExampleHeaderComponent {
  protected readonly children = injectHeaderCellChildren();

  protected readonly style = style;
  protected readonly emoji = emoji;
}
```

**Example: Custom components**

```ts
import { Component, computed } from '@angular/core';

import {
  DataSource,
  InfiniteRender,
  InfiniteTable,
  injectColumnCell,
  injectColumnCellChildren,
  injectHeaderCell,
} from '@infinite-table/infinite-angular';
import type {
  InfiniteTablePropColumns,
  InfiniteTablePropColumnTypes,
} from '@infinite-table/infinite-angular';

type Developer = {
  id: number;
  firstName: string;
  lastName: string;
  country: string;
  city: string;
  currency: string;
  preferredLanguage: string;
  stack: string;
  canDesign: 'yes' | 'no';
  hobby: string;
  salary: number;
  age: number;
};

const dataSource = () => {
  return fetch(process.env.NEXT_PUBLIC_BASE_URL + '/developers1k')
    .then((r) => r.json())
    .then((data: Developer[]) => data);
};

// the host element of the component is the header cell
@Component({
  selector: 'div[defaultHeaderComponent]',
  host: { style: 'border: 1px solid #fefefe' },
  // here you would usually render the default children
  // (`injectHeaderCellChildren()`) and the sort tool, but in this case we
  // want to override the default sort tool as well (which is part of the
  // default children)
  template: `{{ headerCell().column.field }} {{ sortTool() }}`,
})
class DefaultHeaderComponent {
  protected readonly headerCell = injectHeaderCell<Developer>();

  protected readonly sortTool = computed(() => {
    switch (this.headerCell().columnSortInfo?.dir) {
      case undefined:
        return '👉';
      case 1:
        return '👇';
      case -1:
        return '☝🏽';
    }
    return '';
  });
}

// the host element of the component is the cell
@Component({
  selector: 'div[stackComponent]',
  imports: [InfiniteRender],
  host: { '[style]': 'style()' },
  template: `<ng-container [infiniteRender]="children()" />
    <div style="flex: 1"></div>
    {{ emoji() }}`,
})
class StackComponent {
  private readonly cell = injectColumnCell<Developer>();
  // the default content of the cell
  protected readonly children = injectColumnCellChildren();

  private readonly isFrontEnd = computed(
    () => this.cell().value === 'frontend',
  );

  protected readonly emoji = computed(() => (this.isFrontEnd() ? '⚛️' : '💽'));

  protected readonly style = computed(() => ({
    padding: '5px 20px',
    border: `1px solid ${this.isFrontEnd() ? 'red' : 'green'}`,
  }));
}

const columnTypes: InfiniteTablePropColumnTypes<Developer> = {
  default: {
    // override all columns to use these components
    components: {
      HeaderCell: DefaultHeaderComponent,
    },
  },
};

const columns: InfiniteTablePropColumns<Developer> = {
  id: { field: 'id', defaultWidth: 80 },
  stack: {
    field: 'stack',
    renderValue: ({ data }) => 'Stack: ' + data?.stack,
    components: {
      HeaderCell: DefaultHeaderComponent,
      ColumnCell: StackComponent,
    },
  },
  firstName: {
    field: 'firstName',
  },
  preferredLanguage: {
    field: 'preferredLanguage',
  },
};

@Component({
  selector: 'demo-root',
  imports: [DataSource, InfiniteTable],
  template: `
    <infinite-data-source primaryKey="id" [data]="dataSource">
      <infinite-table
        debugId="column-components-example"
        [columns]="columns"
        [columnTypes]="columnTypes"
      />
    </infinite-data-source>
  `,
})
export default class App {
  protected readonly dataSource = dataSource;
  protected readonly columns = columns;
  protected readonly columnTypes = columnTypes;
}
```

### columns.contentFocusable (`boolean|(params) => boolean`)

> Specifies if the column (or cell, if a function is used) renders content that will/should be focusable (via tab-navigation)

**Example: Columns with cell content focusable**

```ts
import { Component, TemplateRef, viewChild } from '@angular/core';

import { DataSource, InfiniteTable } from '@infinite-table/infinite-angular';
import type { InfiniteTablePropColumns } from '@infinite-table/infinite-angular';

type Developer = {
  id: number;
  firstName: string;
  lastName: string;
  country: string;
  city: string;
  currency: string;
  preferredLanguage: string;
  stack: string;
  canDesign: 'yes' | 'no';
  hobby: string;
  salary: number;
  age: number;
};

const dataSource = () => {
  return fetch(process.env.NEXT_PUBLIC_BASE_URL + '/developers1k')
    .then((r) => r.json())
    .then((data: Developer[]) => data);
};

@Component({
  selector: 'demo-root',
  imports: [DataSource, InfiniteTable],
  template: `
    <infinite-data-source primaryKey="id" [data]="dataSource">
      <infinite-table
        debugId="column-contentFocusable-example"
        [columns]="columns"
      />
    </infinite-data-source>

    
    <ng-template #input let-value="value">
      <input
        type="text"
        [value]="value"
        style="background: white; color: black; padding: 2px 10px"
      />
    </ng-template>
  `,
})
export default class App {
  protected readonly dataSource = dataSource;

  private readonly inputTemplate =
    viewChild.required<TemplateRef<unknown>>('input');

  protected readonly columns: InfiniteTablePropColumns<Developer> = {
    id: { field: 'id', defaultWidth: 80 },
    stack: {
      field: 'stack',
      // this makes the column content focusable
      contentFocusable: true,
      renderValue: () => this.inputTemplate(),
    },
    firstName: {
      field: 'firstName',
    },
    preferredLanguage: {
      field: 'preferredLanguage',
      // this makes the column content focusable
      contentFocusable: true,
      renderValue: () => this.inputTemplate(),
    },
  };
}
```

### columns.cssEllipsis (`boolean`)

> Specifies if the column should show ellipsis for content that is too long and does not fit the column width.

For header ellipsis, see related [`headerCssEllipsis`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#headerCssEllipsis).

**Example: First name column(first) has cssEllipsis set to false**

```ts
import { Component } from '@angular/core';

import { DataSource, InfiniteTable } from '@infinite-table/infinite-angular';
import type { InfiniteTablePropColumns } from '@infinite-table/infinite-angular';

type Developer = {
  id: number;
  firstName: string;
  lastName: string;
  country: string;
  city: string;
  currency: string;
  preferredLanguage: string;
  stack: string;
  canDesign: 'yes' | 'no';
  hobby: string;
  salary: number;
  age: number;
};

const dataSource = () => {
  return fetch(process.env.NEXT_PUBLIC_BASE_URL + '/developers1k')
    .then((r) => r.json())
    .then((data: Developer[]) => data);
};

const columns: InfiniteTablePropColumns<Developer> = {
  firstName: {
    field: 'firstName',
    cssEllipsis: false,
    defaultWidth: 60,
  },
  preferredLanguage: {
    field: 'preferredLanguage',
    defaultWidth: 100,
    headerCssEllipsis: false,
    cssEllipsis: true,
  },
  salary: {
    field: 'salary',
    type: 'number',
  },
  stack: { field: 'stack' },
  country: { field: 'country' },
  age: { field: 'age', type: 'number' },
  currency: { field: 'currency', type: 'number' },
};

@Component({
  selector: 'demo-root',
  imports: [DataSource, InfiniteTable],
  template: `
    <infinite-data-source primaryKey="id" [data]="dataSource">
      <infinite-table
        debugId="columns-cssEllipsis-example"
        [columns]="columns"
        [columnDefaultWidth]="200"
      />
    </infinite-data-source>
  `,
})
export default class App {
  protected readonly dataSource = dataSource;
  protected readonly columns = columns;
}
```

### columns.dataType (`string`)

> Specifies the type of the data for the column. For now, it's better to simply use [`columns.type`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#columns.type).

If a column doesn't specify a [sortType](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#columns.sortType), the `dataType` will be used instead to determine the type of sorting to use. If neither `sortType` nor `dataType` are specified, the [column.type](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#columns.type) will be used.

### columns.defaultDraggable (`boolean`)

> Specifies whether the column is draggable by default (for reordering columns).

This property overrides the global [`columnDefaultDraggable`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#columnDefaultDraggable).

### draggableColumns (`boolean`)

> Specifies whether columns are draggable (for reordering columns).

This property overrides the global [`columnDefaultDraggable`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#columnDefaultDraggable) and the column-level [`columns.defaultDraggable`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#columns.defaultDraggable).

### columnDefaultDraggable (`boolean`)

> Specifies whether columns are draggable by default (for reordering columns).

This is overriden by [`columns.defaultDraggable`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#columns.defaultDraggable) and [`draggableColumns`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#draggableColumns).

### columns.defaultEditable (`boolean|(param)=>boolean|Promise<boolean>`)

> Controls if the column is editable or not.

This overrides the global [`columnDefaultEditable`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#columnDefaultEditable).
This is overridden by the [`editable`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#editable) prop.

The value for this property can be either a `boolean` or a function.

If it is a function, it will be called when an edit is triggered on the column. The function will be called with a single object that contains the following properties:

- `value` - the current value of the cell (the value currently displayed, so after [`columns.valueFormatter`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#columns.valueFormatter) and [`columns.renderValue`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#columns.renderValue) have been applied)
- `rawValue` - the current value of the cell, but before any formatting and custom rendering has been applied. This is either the field value from the current data object, or the result of the column [valueGetter](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#columns.valueGetter) function.
- `data` - the data object (of type `DATA_TYPE`) for the current row
- `rowInfo` - the row info object that underlies the row
- `column` - the current column on which editing is invoked
- `api` - a reference to the [InfiniteTable API](https://infinite-table.com/docs/reference/api/index.md)
- `dataSourceApi` - - a reference to the [DataSource API](https://infinite-table.com/angular/docs/reference/datasource-api/index.md)

The function can return a `boolean` value or a `Promise` that resolves to a `boolean` - this means you can asynchronously decide whether the cell is editable or not.

Making [column.defaultEditable](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#columns.defaultEditable) a function gives you the ability to granularly control which cells are editable or not (even within the same column, based on the cell value or other values you have access to).

By default, double-clicking an editable cell will show the cell editor. You can prevent this by returning `{preventEdit: true}` from the [`[onCellDoubleClick]`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#onCellDoubleClick) function prop.

Only the `salary` column is editable.

```ts
import { Component } from '@angular/core';

import { DataSource, InfiniteTable } from '@infinite-table/infinite-angular';
import type { InfiniteTablePropColumns } from '@infinite-table/infinite-angular';

type Developer = {
  id: number;
  firstName: string;
  currency: string;
  stack: string;
  hobby: string;
  salary: string;
};
const dataSource: Developer[] = [
  {
    id: 1,
    firstName: 'John',
    currency: 'USD',
    stack: 'frontend',
    hobby: 'gaming',
    salary: 'USD 1000',
  },
  {
    id: 2,
    firstName: 'Jane',
    currency: 'EUR',
    stack: 'backend',
    hobby: 'reading',
    salary: 'EUR 2000',
  },
  {
    id: 3,
    firstName: 'Jack',
    currency: 'GBP',
    stack: 'frontend',
    hobby: 'gaming',
    salary: 'GBP 3000',
  },
  {
    id: 4,
    firstName: 'Jill',
    currency: 'USD',
    stack: 'backend',
    hobby: 'reading',
    salary: 'USD 4000',
  },
];

const columns: InfiniteTablePropColumns<Developer> = {
  id: { field: 'id', defaultWidth: 80 },

  salary: {
    // the only editable column
    defaultEditable: true,

    defaultWidth: 320,
    field: 'salary',
    header: 'Salary - edit accepts numbers only',
    style: { color: 'tomato' },
    getValueToEdit: ({ value }) => {
      return parseInt(value.substr(4), 10);
    },
    getValueToPersist: ({ value, data }) => {
      return `${data!.currency} ${parseInt(value, 10)}`;
    },
  },

  firstName: {
    field: 'firstName',
    header: 'Name',
  },
  currency: {
    field: 'currency',
    header: 'Currency',
  },
};

const shouldAcceptEdit = ({ value }: { value: any }) => {
  return parseInt(value, 10) == value;
};

@Component({
  selector: 'demo-root',
  imports: [DataSource, InfiniteTable],
  template: `
    <infinite-data-source primaryKey="id" [data]="dataSource">
      <infinite-table
        debugId="global-should-accept-edit-example"
        [columns]="columns"
        [columnDefaultEditable]="false"
        [shouldAcceptEdit]="shouldAcceptEdit"
      />
    </infinite-data-source>
  `,
})
export default class App {
  protected readonly dataSource = dataSource;
  protected readonly columns = columns;
  protected readonly shouldAcceptEdit = shouldAcceptEdit;
}
```

### columns.defaultFlex (`number`)

> Specifies a default flex for the column

If you want more control on sizing, use controlled [`[(columnSizing)]`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#columnSizing) (or uncontrolled [`defaultColumnSizing`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#defaultColumnSizing)).

See related [`columns.defaultWidth`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#columns.defaultWidth)

### columnGroupVisibility (`Record<string, boolean>`)

> Controls the visibility of column groups. By default, column groups are visible.

```ts
@Component({
  selector: 'developers-grid',
  imports: [InfiniteTable],
  template: `
    <infinite-table
      [(columnGroupVisibility)]="columnGroupVisibility"
      [columns]="columns"
    />
  `,
})
export class DevelopersGrid {
  protected readonly columns = columns;

  protected readonly columnGroupVisibility =
    signal<InfiniteTablePropColumnGroupVisibility>({
      country: false,
      city: true,
    });
}
```

### columns.defaultHiddenWhenGroupedBy (`'*'| true | keyof DATA_TYPE | { [keyof DATA_TYPE]: true }`)

> Controls default column visibility when [`[(groupBy)]`](https://infinite-table.com/angular/docs/reference/datasource-props/index.md#groupBy) is used.

This property does not apply (work) when controlled [`[(columnVisibility)]`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#columnVisibility) is used, it only works with uncontrolled column visibility.

The value for this property can be one of the following:

- the `'*'` string - this means, the column is hidden whenever there are groups - so any groups.
- a `string`, namely a field from the bound type of the `DataSource` (so type is `keyof DATA_TYPE`) - the column is hidden whenever there is grouping that includes the specified field. The grouping can contain any other fields, but if it includes the specified field, the column is hidden.
- `true` - the column is hidden when there grouping that uses the field that the column is bound to.
- `an object with keys` of type `keyof DATA_TYPE` and values being `true` - whenever the grouping includes any of the fields that are in the keys of this object, the column is hidden.

```ts
import { Component } from '@angular/core';

import { DataSource, InfiniteTable } from '@infinite-table/infinite-angular';
import type {
  DataSourceGroupBy,
  InfiniteTablePropColumnSizing,
  InfiniteTablePropColumns,
} from '@infinite-table/infinite-angular';

type Developer = {
  id: number;
  firstName: string;
  lastName: string;
  country: string;
  city: string;
  currency: string;
  preferredLanguage: string;
  stack: string;
  canDesign: 'yes' | 'no';
  hobby: string;
  salary: number;
  age: number;
};

const columns: InfiniteTablePropColumns<Developer> = {
  id: { field: 'id' },
  firstName: { field: 'firstName' },
  preferredLanguage: {
    field: 'preferredLanguage',
    // hide whenever grouped by preferredLanguage
    defaultHiddenWhenGroupedBy: 'preferredLanguage',
  },
  stack: { field: 'stack' },
  country: { field: 'country' },
  canDesign: { field: 'canDesign' },
  hobby: { field: 'hobby' },

  city: {
    field: 'city',
    // hide whenever grouped by country or city
    defaultHiddenWhenGroupedBy: {
      country: true,
      city: true,
    },
  },
  age: { field: 'age' },
  salary: {
    field: 'salary',
    type: 'number',
    // hide whenever there is grouping
    defaultHiddenWhenGroupedBy: '*',
  },
  currency: { field: 'currency' },
};

const columnSizing: InfiniteTablePropColumnSizing = {
  country: { width: 100 },
  city: { flex: 1, minWidth: 100 },
  salary: { flex: 2, maxWidth: 500 },
};

const defaultGroupBy: DataSourceGroupBy<Developer>[] = [
  { field: 'stack' },
  { field: 'preferredLanguage' },
  { field: 'country' },
];

@Component({
  selector: 'demo-root',
  imports: [DataSource, InfiniteTable],
  template: `
    <infinite-data-source
      [data]="dataSource"
      [defaultGroupBy]="defaultGroupBy"
      primaryKey="id"
    >
      <infinite-table
        debugId="columnDefaultHiddenWhenGroupedBy-example"
        [columns]="columns"
        [columnDefaultWidth]="250"
        [columnSizing]="columnSizing"
      />
    </infinite-data-source>
  `,
})
export default class App {
  protected readonly dataSource = dataSource;
  protected readonly columns = columns;
  protected readonly columnSizing = columnSizing;
  protected readonly defaultGroupBy = defaultGroupBy;
}

const dataSource = () => {
  return fetch(process.env.NEXT_PUBLIC_BASE_URL + '/developers1k')
    .then((r) => r.json())
    .then((data: Developer[]) => data);
};
```

### columns.defaultWidth (`number`)

> Specifies a default width for the column

If you want more control on sizing, use controlled [`[(columnSizing)]`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#columnSizing) (or uncontrolled [`defaultColumnSizing`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#defaultColumnSizing)).

See related [`columns.defaultFlex`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#columns.defaultFlex)

### columns.field (`keyof DATA_TYPE`)

> Binds the column to the specified data field. It should be a keyof `DATA_TYPE`.

It can be the same or different to the column id. This is not used for referencing the column in various other props - the column key (column id) is used for that.

If no [`columns.header`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#columns.header) is specified, it will be used as the column header.

```ts
import { Component } from '@angular/core';

import { DataSource, InfiniteTable } from '@infinite-table/infinite-angular';
import type { InfiniteTablePropColumns } from '@infinite-table/infinite-angular';

import { data } from './data';
import type { Person } from './data';

const columns: InfiniteTablePropColumns<Person> = {
  identifier: {
    field: 'Id',
    type: 'number',
    defaultSortable: true,
    defaultWidth: 80,
  },
  firstName: {
    field: 'FirstName',
  },
  age: { field: 'Age', type: 'number' },
};

@Component({
  selector: 'demo-root',
  imports: [DataSource, InfiniteTable],
  template: `
    <infinite-data-source [data]="data" primaryKey="Id">
      <infinite-table debugId="columns-example" [columns]="columns" />
    </infinite-data-source>
  `,
})
export default class App {
  protected readonly data = data;
  protected readonly columns = columns;
}
```

Group columns can also be bound to a field, like in the snippet below.

In this example, the group column is bound to the `firstName` field, so this field will be rendered in non-group rows for this column.

```ts
import { Component } from '@angular/core';

import { DataSource, InfiniteTable } from '@infinite-table/infinite-angular';
import type {
  DataSourceProps,
  InfiniteTablePropColumns,
  InfiniteTableProps,
} from '@infinite-table/infinite-angular';

const columns: InfiniteTablePropColumns<Developer> = {
  country: {
    field: 'country',
  },
  firstName: {
    field: 'firstName',
    defaultHiddenWhenGroupedBy: '*',
  },
  stack: {
    field: 'stack',
  },
  age: { field: 'age' },
  id: { field: 'id' },
  preferredLanguage: {
    field: 'preferredLanguage',
  },
  canDesign: {
    field: 'canDesign',
    renderGroupValue: ({ value }) => `Can design: ${value || ''}`,
  },
};

const defaultGroupBy: DataSourceProps<Developer>['groupBy'] = [
  {
    field: 'canDesign',
  },
  {
    field: 'stack',
  },
  {
    field: 'preferredLanguage',
  },
];

const groupColumn: InfiniteTableProps<Developer>['groupColumn'] = {
  field: 'firstName',
  renderSelectionCheckBox: true,
  defaultWidth: 300,
};

const domProps = {
  style: {
    flex: 1,
    minHeight: 500,
  },
};

@Component({
  selector: 'demo-root',
  imports: [DataSource, InfiniteTable],
  template: `
    <infinite-data-source
      [data]="dataSource"
      [groupBy]="defaultGroupBy"
      selectionMode="multi-row"
      primaryKey="id"
    >
      <infinite-table
        debugId="group-column-bound-to-field-example"
        [columns]="columns"
        [domProps]="domProps"
        [groupColumn]="groupColumn"
        [columnDefaultWidth]="150"
      />
    </infinite-data-source>
  `,
})
export default class App {
  protected readonly dataSource = dataSource;
  protected readonly columns = columns;
  protected readonly defaultGroupBy = defaultGroupBy;
  protected readonly groupColumn = groupColumn;
  protected readonly domProps = domProps;
}

const dataSource = () => {
  return fetch(process.env.NEXT_PUBLIC_BASE_URL + '/developers100')
    .then((r) => r.json())
    .then((data: Developer[]) => data);
};

type Developer = {
  id: number;
  firstName: string;
  lastName: string;
  country: string;
  city: string;
  currency: string;
  email: string;
  preferredLanguage: string;
  stack: string;
  canDesign: 'yes' | 'no';
  hobby: string;
  salary: number;
  age: number;
};
```

### columns.filterType (`string`)

> Use this to configure the filter type for the column, when the `filterType` needs to be different from the column [type](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#columns.type).

See related [`columns.type`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#columns.type)

If the type of filter you want to show does not match the column [type](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#columns.type), you can specify the filter with the [column.filterType](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#columns.filterType) property. Only use this when the type of the data differs from the type of the filter (eg: you have a numeric column, with a custom filter type).

In this example, the `salary` column has `type="number"` and `filterType="salary"`.

This means the sort order defined for `type="number"` will be used while displaying a custom type of filter.

**Example: Custom column filterType for the salary column**

```ts
import { Component, input } from '@angular/core';

import {
  DataSource,
  InfiniteTable,
  renderComponent,
} from '@infinite-table/infinite-angular';
import type {
  DataSourceData,
  DataSourcePropFilterTypes,
  DataSourcePropFilterValue,
  InfiniteTablePropColumns,
} from '@infinite-table/infinite-angular';

type Developer = {
  id: number;
  firstName: string;
  lastName: string;

  currency: string;
  preferredLanguage: string;
  stack: string;
  canDesign: 'yes' | 'no';

  salary: number;
};

const data: DataSourceData<Developer> = () => {
  return fetch(process.env.NEXT_PUBLIC_BASE_URL + `/developers1k-sql?`)
    .then((r) => r.json())
    .then((data: Developer[]) => data);
};

const columns: InfiniteTablePropColumns<Developer> = {
  id: {
    field: 'id',
    type: 'number',
    defaultWidth: 100,
  },
  salary: {
    defaultFilterable: true,
    field: 'salary',
    type: 'number',
    filterType: 'salary',
  },

  firstName: {
    field: 'firstName',
  },
  stack: { field: 'stack' },
  currency: { field: 'currency', defaultFilterable: false },
};

// the icon of a filter operator
@Component({
  selector: 'div[operatorIcon]',
  host: {
    style:
      'width: 20px; display: flex; justify-content: center; flex-flow: row',
  },
  template: `{{ icon() }}`,
})
class OperatorIcon {
  readonly icon = input.required<string>();
}

function getIcon(icon: string) {
  return () => renderComponent(OperatorIcon, { inputs: { icon } });
}

const filterTypes: DataSourcePropFilterTypes<Developer> = {
  salary: {
    defaultOperator: 'gt',
    emptyValues: ['', null, undefined],
    operators: [
      {
        name: 'gt',
        label: 'Salary Greater Than',
        components: {
          Icon: getIcon('>'),
        },
        fn: ({ currentValue, filterValue }) => {
          return currentValue > filterValue;
        },
      },
      {
        name: 'gte',
        components: {
          Icon: getIcon('>='),
        },
        label: 'Salary Greater Than or Equal',
        fn: ({ currentValue, filterValue }) => {
          return currentValue >= filterValue;
        },
      },
      {
        name: 'lt',
        components: {
          Icon: getIcon('<'),
        },
        label: 'Salary Less Than',
        fn: ({ currentValue, filterValue }) => {
          return currentValue < filterValue;
        },
      },
      {
        name: 'lte',
        components: {
          Icon: getIcon('<='),
        },
        label: 'Salary Less Than or Equal',
        fn: ({ currentValue, filterValue }) => {
          return currentValue <= filterValue;
        },
      },
    ],
  },
};

const domProps = {
  style: {
    height: '100%',
  },
};

const defaultFilterValue: DataSourcePropFilterValue<Developer> = [];

@Component({
  selector: 'demo-root',
  imports: [DataSource, InfiniteTable],
  template: `
    <infinite-data-source
      [data]="data"
      primaryKey="id"
      [defaultFilterValue]="defaultFilterValue"
      [filterDelay]="0"
      [filterTypes]="filterTypes"
    >
      <infinite-table
        debugId="column-filterType-example"
        [domProps]="domProps"
        [columnDefaultWidth]="150"
        [columnMinWidth]="50"
        [columns]="columns"
      />
    </infinite-data-source>
  `,
})
export default class App {
  protected readonly data = data;
  protected readonly columns = columns;
  protected readonly filterTypes = filterTypes;
  protected readonly domProps = domProps;
  protected readonly defaultFilterValue = defaultFilterValue;
}
```

### columns.getValueToEdit (`(params) => any|Promise<any>`)

> Allows customizing the value that will be passed to the cell editor when it is displayed (when editing starts).

The function is called with an object that has the following properties:

- `value` - the value of the cell (the value that is displayed in the cell before editing starts). This is the value resulting after [`columns.valueFormatter`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#columns.valueFormatter) and [`columns.renderValue`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#columns.renderValue) have been applied)
- `rawValue` - the raw value of the cell, before any formatting and custom rendering has been applied. This is either the field value from the current data object, or the result of the column [valueGetter](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#columns.valueGetter) function.
- `data` - the current data object
- `rowInfo` - the row info object that underlies the row
- `column` - the current column on which editing is invoked
- `api` - a reference to the [InfiniteTable API](https://infinite-table.com/docs/reference/api/index.md)
- `dataSourceApi` - - a reference to the [DataSource API](https://infinite-table.com/angular/docs/reference/datasource-api/index.md)

This function can be async. Return a `Promise` to wait for the value to be resolved and then passed to the cell editor.

See related [`columns.getValueToPersist`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#columns.getValueToPersist) and [`columns.shouldAcceptEdit`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#columns.shouldAcceptEdit).

In this example, the `salary` for each row includes the currency string.

<p>When editing starts, we want to remove the currency string and only show the numeric value in the editor - we do this via [`columns.getValueToEdit`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#columns.getValueToEdit).</p>

```ts
import { Component } from '@angular/core';

import { DataSource, InfiniteTable } from '@infinite-table/infinite-angular';
import type { InfiniteTablePropColumns } from '@infinite-table/infinite-angular';

type Developer = {
  id: number;
  firstName: string;
  currency: string;
  stack: string;
  hobby: string;
  salary: string;
};
const dataSource: Developer[] = [
  {
    id: 1,
    firstName: 'John',
    currency: 'USD',
    stack: 'frontend',
    hobby: 'gaming',
    salary: 'USD 1000',
  },
  {
    id: 2,
    firstName: 'Jane',
    currency: 'EUR',
    stack: 'backend',
    hobby: 'reading',
    salary: 'EUR 2000',
  },
  {
    id: 3,
    firstName: 'Jack',
    currency: 'GBP',
    stack: 'frontend',
    hobby: 'gaming',
    salary: 'GBP 3000',
  },
  {
    id: 4,
    firstName: 'Jill',
    currency: 'USD',
    stack: 'backend',
    hobby: 'reading',
    salary: 'USD 4000',
  },
];

const columns: InfiniteTablePropColumns<Developer> = {
  id: { field: 'id', defaultWidth: 80, defaultEditable: false },

  salary: {
    defaultWidth: 320,
    field: 'salary',
    header: 'Salary - edit accepts numbers only',
    style: { color: 'tomato' },
    getValueToEdit: ({ value }) => {
      return parseInt(value.substr(4), 10);
    },
    getValueToPersist: ({ value, data }) => {
      return `${data!.currency} ${parseInt(value, 10)}`;
    },
    shouldAcceptEdit: ({ value }) => {
      return parseInt(value, 10) == value;
    },
  },

  firstName: {
    field: 'firstName',
    header: 'Name',
  },
  currency: {
    field: 'currency',
    header: 'Currency',
  },
};

@Component({
  selector: 'demo-root',
  imports: [DataSource, InfiniteTable],
  template: `
    <infinite-data-source primaryKey="id" [data]="dataSource">
      <infinite-table
        debugId="inline-editing-custom-edit-value-example"
        [columns]="columns"
        [columnDefaultEditable]="true"
      />
    </infinite-data-source>
  `,
})
export default class App {
  protected readonly dataSource = dataSource;
  protected readonly columns = columns;
}
```

### columns.getValueToPersist (`(params) => any|Promise<any>`)

> Allows customizing the value that will be persisted when an edit has been accepted.

The function is called with an object that has the following properties:

- `initialValue` - the initial value of the cell (the value that was displayed in the cell before editing started). This is the value resulting after [`columns.valueFormatter`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#columns.valueFormatter) and [`columns.renderValue`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#columns.renderValue) have been applied)
- `value` - the current value that was accepted as an edit and which came from the cell editor.
- `rawValue` - the raw value of the cell, before any formatting and custom rendering has been applied. This is either the field value from the current data object, or the result of the column [valueGetter](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#columns.valueGetter) function.
- `data` - the current data object
- `rowInfo` - the row info object that underlies the row
- `column` - the current column on which editing is invoked
- `api` - a reference to the [InfiniteTable API](https://infinite-table.com/docs/reference/api/index.md)
- `dataSourceApi` - - a reference to the [DataSource API](https://infinite-table.com/angular/docs/reference/datasource-api/index.md)

This function can be async. Return a `Promise` to wait for the value to be resolved and then persisted.

See related [`columns.getValueToEdit`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#columns.getValueToEdit) and [`columns.shouldAcceptEdit`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#columns.shouldAcceptEdit).

In this example, the `salary` for each row includes the currency string.

<p>When an edit is accepted, we want the persisted value to include the currency string as well (like the original value did) - we do this via [`columns.getValueToPersist`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#columns.getValueToPersist).</p>

```ts
import { Component } from '@angular/core';

import { DataSource, InfiniteTable } from '@infinite-table/infinite-angular';
import type { InfiniteTablePropColumns } from '@infinite-table/infinite-angular';

type Developer = {
  id: number;
  firstName: string;
  currency: string;
  stack: string;
  hobby: string;
  salary: string;
};
const dataSource: Developer[] = [
  {
    id: 1,
    firstName: 'John',
    currency: 'USD',
    stack: 'frontend',
    hobby: 'gaming',
    salary: 'USD 1000',
  },
  {
    id: 2,
    firstName: 'Jane',
    currency: 'EUR',
    stack: 'backend',
    hobby: 'reading',
    salary: 'EUR 2000',
  },
  {
    id: 3,
    firstName: 'Jack',
    currency: 'GBP',
    stack: 'frontend',
    hobby: 'gaming',
    salary: 'GBP 3000',
  },
  {
    id: 4,
    firstName: 'Jill',
    currency: 'USD',
    stack: 'backend',
    hobby: 'reading',
    salary: 'USD 4000',
  },
];

const columns: InfiniteTablePropColumns<Developer> = {
  id: { field: 'id', defaultWidth: 80, defaultEditable: false },

  salary: {
    defaultWidth: 320,
    field: 'salary',
    header: 'Salary - edit accepts numbers only',
    style: { color: 'tomato' },
    getValueToEdit: ({ value }) => {
      return parseInt(value.substr(4), 10);
    },
    getValueToPersist: ({ value, data }) => {
      return `${data!.currency} ${parseInt(value, 10)}`;
    },
    shouldAcceptEdit: ({ value }) => {
      return parseInt(value, 10) == value;
    },
  },

  firstName: {
    field: 'firstName',
    header: 'Name',
  },
  currency: {
    field: 'currency',
    header: 'Currency',
  },
};

@Component({
  selector: 'demo-root',
  imports: [DataSource, InfiniteTable],
  template: `
    <infinite-data-source primaryKey="id" [data]="dataSource">
      <infinite-table
        debugId="inline-editing-custom-edit-value-example"
        [columns]="columns"
        [columnDefaultEditable]="true"
      />
    </infinite-data-source>
  `,
})
export default class App {
  protected readonly dataSource = dataSource;
  protected readonly columns = columns;
}
```

### columns.renderHeader (`(param: InfiniteTableColumnHeaderParam) => ReactNode`)

> A custom rendering function for the column header. Called with an object of type [`InfiniteTableColumnHeaderParam`](https://infinite-table.com/docs/reference/type-definitions/index.md#InfiniteTableColumnHeaderParam).

It's the equivalent of [`columns.renderValue`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#columns.renderValue) but for the [column.header](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#columns.header).

It gives you access to the column, along with information about sorting, filtering, grouping, etc.

It is called with a single argument, of type [`InfiniteTableColumnHeaderParam`](https://infinite-table.com/docs/reference/type-definitions/index.md#InfiniteTableColumnHeaderParam).

### columns.header (`React.ReactNode|({column, columnSortInfo, columnApi})=>React.ReactNode`)

> Specifies the column header. Can be a static value or a function that returns a React node.

If no `header` is specified for a column, the [field](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#columns.field) will be used instead.

If a function is provided, it will be called with an argument with the following properties:

- `column`
- `columnSortInfo` - will allow you to render custom header based on the sort state of the column.
- `columnApi` - [API](https://infinite-table.com/docs/reference/column-api/index.md) for the current column. Can be useful if you customize the header and want to programatically trigger actions like sorting, show/hide column menu, etc.

When we implement filtering, you'll also have access to the column filter.

For styling the column header, you can use [headerStyle](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#columns.headerStyle) or [headerClassName](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#columns.headerClassName).

For configuring the column header height, see the [`columnHeaderHeight`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#columnHeaderHeight) prop.

```ts
import { Component } from '@angular/core';

import { DataSource, InfiniteTable } from '@infinite-table/infinite-angular';
import type { InfiniteTableColumn } from '@infinite-table/infinite-angular';

import { data } from './data';
import type { Person } from './data';

const columns: Record<string, InfiniteTableColumn<Person>> = {
  id: {
    field: 'Id',
    header: '🎉 Identifier',
    type: 'number',
    defaultSortable: true,
    defaultWidth: 140,
  },
  firstName: {
    field: 'FirstName',
    header: 'Name',
    defaultWidth: 120,
  },
  age: { field: 'Age', type: 'number', defaultWidth: 100 },
};

@Component({
  selector: 'demo-root',
  imports: [DataSource, InfiniteTable],
  template: `
    <infinite-data-source [data]="data" primaryKey="Id">
      <infinite-table debugId="columns-header-example" [columns]="columns" />
    </infinite-data-source>
  `,
})
export default class App {
  protected readonly data = data;
  protected readonly columns = columns;
}
```

The `column.header` function can return a string, a `TemplateRef` (it gets the column as `$implicit` and the param's properties by name) or a component (`renderComponent(...)`), which reads the same param with [`injectHeaderCell`](https://infinite-table.com/docs/reference/hooks/index.md#useInfiniteHeaderCell). To replace the whole header cell, use [column.components.HeaderCell](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#columns.components.HeaderCell).

**Example: Column with custom header that uses useInfiniteHeaderCell**

```ts
import { Component } from '@angular/core';

import {
  DataSource,
  InfiniteTable,
  injectHeaderCell,
} from '@infinite-table/infinite-angular';
import type { InfiniteTablePropColumns } from '@infinite-table/infinite-angular';

type Developer = {
  id: number;
  firstName: string;
  lastName: string;
  country: string;
  city: string;
  currency: string;
  preferredLanguage: string;
  stack: string;
  canDesign: 'yes' | 'no';
  hobby: string;
  salary: number;
  age: number;
};

const dataSource = () => {
  return fetch(process.env.NEXT_PUBLIC_BASE_URL + '/developers1k')
    .then((r) => r.json())
    .then((data: Developer[]) => data);
};

// the host element of the component is the header cell
@Component({
  selector: 'div[hobbyHeader]',
  template: `<b style="color: #0000c2">{{ headerCell().column.field }} 🤷📸👨🏻‍🍳💃📚⛹️</b>`,
})
class HobbyHeader {
  
  protected readonly headerCell = injectHeaderCell<Developer>();
}

const columns: InfiniteTablePropColumns<Developer> = {
  id: { field: 'id', maxWidth: 80 },
  stack: {
    field: 'stack',
  },
  hobby: {
    field: 'hobby',
    components: {
      HeaderCell: HobbyHeader,
    },
  },
};

@Component({
  selector: 'demo-root',
  imports: [DataSource, InfiniteTable],
  template: `
    <infinite-data-source primaryKey="id" [data]="dataSource">
      <infinite-table
        debugId="column-header-hooks-example"
        [columns]="columns"
        [columnDefaultWidth]="200"
      />
    </infinite-data-source>
  `,
})
export default class App {
  protected readonly dataSource = dataSource;
  protected readonly columns = columns;
}
```

The `preferredLanguage` column has a custom header that shows a button for triggering the column context menu.

In addition, the currency and preferredLanguage columns have a custom context menu icon.

**Example: Custom header with button to trigger the column context menu**

```ts
import { Component, TemplateRef, viewChild } from '@angular/core';

import {
  DataSource,
  InfiniteTable,
  renderTemplate,
} from '@infinite-table/infinite-angular';
import type {
  InfiniteTablePropColumns,
  InfiniteTablePropGetColumnMenuItems,
} from '@infinite-table/infinite-angular';

type Developer = {
  id: number;
  firstName: string;
  lastName: string;
  country: string;
  city: string;
  currency: string;
  preferredLanguage: string;
  stack: string;
  canDesign: 'yes' | 'no';
  hobby: string;
  salary: number;
  age: number;
};

const dataSource = () => {
  return fetch(process.env.NEXT_PUBLIC_BASE_URL + '/developers1k')
    .then((r) => r.json())
    .then((data: Developer[]) => data);
};

const getColumnMenuItems: InfiniteTablePropGetColumnMenuItems<Developer> = (
  items,
  { column },
) => {
  if (column.id === 'firstName') {
    // you can adjust the default items for a specific column
    items.splice(0, 0, {
      key: 'firstName',
      label: 'First name menu item',
      onAction: () => {
        console.log('Hey there!');
      },
    });
  }

  items.push(
    {
      key: 'hello',
      label: 'Hello World',
      onAction: () => {
        alert('Hello World from column ' + column.id);
      },
    },
    {
      key: 'translate',
      label: 'Translate',
      menu: {
        items: [
          {
            key: 'translateToEnglish',
            label: 'English',
            onAction: () => {
              console.log('Translate to English');
            },
          },
          {
            key: 'translateToFrench',
            label: 'French',
            onAction: () => {
              console.log('Translate to French');
            },
          },
        ],
      },
    },
  );
  return items;
};

@Component({
  selector: 'demo-root',
  imports: [DataSource, InfiniteTable],
  template: `
    <infinite-data-source primaryKey="id" [data]="dataSource">
      <infinite-table
        debugId="getColumnMenuItems-example"
        [columnHeaderHeight]="70"
        [columns]="columns"
        [getColumnMenuItems]="getColumnMenuItems"
      />
    </infinite-data-source>

    <!-- custom menu icon -->
    <ng-template #globe>
      <div>🌎</div>
    </ng-template>

    
    <ng-template #languageHeader let-columnApi="columnApi">
      Preferred Language
      <!-- stop the propagation of pointerdown, so a click on the button doesn't sort the column, and of mousedown, so the menu is not closed automatically: the button toggles it -->
      <button
        style="border: 1px solid magenta; margin: 2px"
        (pointerdown)="$event.stopPropagation()"
        (mousedown)="
          $event.stopPropagation(); columnApi.toggleContextMenu($event.target)
        "
      >
        Toggle menu
      </button>
    </ng-template>
  `,
})
export default class App {
  protected readonly dataSource = dataSource;
  protected readonly getColumnMenuItems = getColumnMenuItems;

  private readonly globeTemplate =
    viewChild.required<TemplateRef<unknown>>('globe');
  private readonly languageHeaderTemplate =
    viewChild.required<TemplateRef<unknown>>('languageHeader');

  protected readonly columns: InfiniteTablePropColumns<Developer> = {
    currency: {
      field: 'currency',

      // custom menu icon
      renderMenuIcon: () => this.globeTemplate(),
    },

    preferredLanguage: {
      field: 'preferredLanguage',
      defaultWidth: 350,
      header: ({ columnApi, renderLocation }) => {
        // if we're inside the column menu with all columns, return only the col name
        if (renderLocation === 'column-menu') {
          return 'Preferred Language';
        }

        // but for the real column header
        // return this custom content
        return renderTemplate(this.languageHeaderTemplate(), { columnApi });
      },

      // custom menu icon
      renderMenuIcon: () => this.globeTemplate(),
    },
    salary: {
      field: 'salary',
      // hide the menu icon
      renderMenuIcon: false,
    },
    country: {
      field: 'country',
    },
    id: { field: 'id', defaultWidth: 80, renderMenuIcon: false },
    firstName: {
      field: 'firstName',
    },
  };
}
```

### columns.headerClassName (`string | (args) => string`)

> Controls the css class name for the column header. Can be a string or a function returning a string.

If defined as a function, it accepts an object as a parameter, which has the following properties:

- `column` - the current column where the style is being applied
- `columnSortInfo` - the sorting information for the column
- `columnFilterValue` - the filtering information for the column
- `dragging` - whether the current column is being dragged at the current time (during a column reorder)

The `headerClassName` property can also be specified for [columnTypes](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#columnTypes.headerClassName).

For styling with inline styles, see [`columns.headerStyle`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#columns.headerStyle).

### columns.headerCssEllipsis (`boolean`)

> Specifies if the column should show ellipsis in the column header if the header is too long and does not fit the column width.

If this property is not specified, the value of [`columns.cssEllipsis`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#columns.cssEllipsis) will be used.

For normal cell ellipsis, see related [`cssEllipsis`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#cssEllipsis).

**Example: Preferred Language column(second) has headerCssEllipsis set to false**

```ts
import { Component } from '@angular/core';

import { DataSource, InfiniteTable } from '@infinite-table/infinite-angular';
import type { InfiniteTablePropColumns } from '@infinite-table/infinite-angular';

type Developer = {
  id: number;
  firstName: string;
  lastName: string;
  country: string;
  city: string;
  currency: string;
  preferredLanguage: string;
  stack: string;
  canDesign: 'yes' | 'no';
  hobby: string;
  salary: number;
  age: number;
};

const dataSource = () => {
  return fetch(process.env.NEXT_PUBLIC_BASE_URL + '/developers1k')
    .then((r) => r.json())
    .then((data: Developer[]) => data);
};

const columns: InfiniteTablePropColumns<Developer> = {
  firstName: {
    field: 'firstName',
    cssEllipsis: false,
    defaultWidth: 60,
  },
  preferredLanguage: {
    field: 'preferredLanguage',
    defaultWidth: 100,
    headerCssEllipsis: false,
    cssEllipsis: true,
  },
  salary: {
    field: 'salary',
    type: 'number',
  },
  stack: { field: 'stack' },
  country: { field: 'country' },
  age: { field: 'age', type: 'number' },
  currency: { field: 'currency', type: 'number' },
};

@Component({
  selector: 'demo-root',
  imports: [DataSource, InfiniteTable],
  template: `
    <infinite-data-source primaryKey="id" [data]="dataSource">
      <infinite-table
        debugId="columns-cssEllipsis-example"
        [columns]="columns"
        [columnDefaultWidth]="200"
      />
    </infinite-data-source>
  `,
})
export default class App {
  protected readonly dataSource = dataSource;
  protected readonly columns = columns;
}
```

### columns.headerStyle (`CSSProperties | (args) => CSSProperties`)

> Controls styling for the column header. Can be a style object or a function returning a style object.

If defined as a function, it accepts an object as a parameter, which has the following properties:

- `column` - the current column where the style is being applied
- `columnSortInfo` - the sorting information for the column
- `columnFilterValue` - the filtering information for the column
- `dragging` - whether the current column is being dragged at the current time (during a column reorder)

The `headerStyle` property can also be specified for [columnTypes](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#columnTypes.headerStyle).

For styling with CSS, see [`columns.headerClassName`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#columns.headerClassName).

For configuring the column header height, see the [`columnHeaderHeight`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#columnHeaderHeight) prop.

### columns.maxWidth (`number`)

> Configures the maximum width for the column.

If not specified, [`columnMaxWidth`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#columnMaxWidth) will be used (defaults to `2000`).

### columns.minWidth (`number`)

> Configures the minimum width for the column.

If not specified, [`columnMinWidth`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#columnMinWidth) will be used (defaults to `30`).

### columns.render (`(cellContext) => Renderable`)

> Customizes the rendering of the column. The argument passed to the function is an object of type [`InfiniteTableColumnCellContextType`](https://infinite-table.com/docs/reference/type-definitions/index.md#InfiniteTableColumnCellContextType)

See related [`columns.renderValue`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#columns.renderValue), [`columns.renderGroupValue`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#columns.renderGroupValue)

The difference between [`columns.render`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#columns.render) and [`columns.renderValue`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#columns.renderValue) is only for special columns (for now, only group columns are special columns, but more will come) when `InfiniteTable` renders additional content inside the column (eg: collapse/expand tool for group rows). The [`columns.render`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#columns.render) function allows you to override the additional content. So if you specify this function, it's up to you to render whatever content, including the collapse/expand tool.

Note that for customizing the collapse/expand tool, you can use specify `renderGroupIcon` function on the group column.

To understand how the rendering pipeline works, head over to the page on [Column rendering](https://infinite-table.com/angular/docs/learn/columns/column-rendering.md#rendering-pipeline).

The [render](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#columns.render) and [renderValue](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#columns.renderValue) functions are called with an object that has the following properties:

- data - the data object (of type `DATA_TYPE | Partial<DATA_TYPE> | null`) for the row.
- rowInfo - very useful information about the current row. See [Using RowInfo](https://infinite-table.com/angular/docs/learn/rows/using-row-info.md) for more details.
- renderBag - read more about this in the docs for [Column rendering pipeline](https://infinite-table.com/angular/docs/learn/columns/column-rendering.md#rendering-pipeline)

**Example: Column with custom render**

```ts
import { Component, TemplateRef, viewChild } from '@angular/core';

import { DataSource, InfiniteTable } from '@infinite-table/infinite-angular';
import type {
  DataSourceGroupBy,
  InfiniteTablePropColumns,
  InfiniteTablePropGroupColumn,
} from '@infinite-table/infinite-angular';

type Developer = {
  id: number;
  firstName: string;
  lastName: string;
  country: string;
  city: string;
  currency: string;
  preferredLanguage: string;
  stack: string;
  canDesign: 'yes' | 'no';
  hobby: string;
  salary: number;
  age: number;
};

const dataSource = () => {
  return fetch(process.env.NEXT_PUBLIC_BASE_URL + '/developers1k')
    .then((r) => r.json())
    .then((data: Developer[]) => data);
};

const columns: InfiniteTablePropColumns<Developer> = {
  id: { field: 'id', defaultWidth: 80 },
  stack: {
    field: 'stack',
  },
  firstName: {
    field: 'firstName',
  },
  preferredLanguage: { field: 'preferredLanguage' },
};

const defaultGroupBy: DataSourceGroupBy<Developer>[] = [{ field: 'stack' }];

@Component({
  selector: 'demo-root',
  imports: [DataSource, InfiniteTable],
  template: `
    <infinite-data-source
      primaryKey="id"
      [data]="dataSource"
      [defaultGroupBy]="defaultGroupBy"
    >
      <infinite-table
        debugId="column-render-example"
        [groupColumn]="groupColumn"
        [columns]="columns"
        [columnDefaultWidth]="200"
      />
    </infinite-data-source>

    
    <ng-template
      #groupCell
      let-rowInfo="rowInfo"
      let-toggleCurrentGroupRow="toggleCurrentGroupRow"
    >
      <div
        style="cursor: pointer; display: flex; align-items: center"
        [style.color]="rowInfo.collapsed ? '#b00000' : 'blue'"
        (click)="toggleCurrentGroupRow()"
      >
        <!-- &ngsp; is a space Angular keeps between two elements -->
        <i style="margin-right: 5px">Grouped by</i>&ngsp;<b>{{ rowInfo.value }}</b>
        <svg
          style="display: inline-block"
          [style.fill]="rowInfo.collapsed ? '#b00000' : 'blue'"
          width="20px"
          height="20px"
          viewBox="0 0 24 24"
          fill="#000000"
        >
          @if (rowInfo.collapsed) {
            <path d="M0 0h24v24H0V0z" fill="none" />
            <path
              d="M12 5.83L15.17 9l1.41-1.41L12 3 7.41 7.59 8.83 9 12 5.83zm0 12.34L8.83 15l-1.41 1.41L12 21l4.59-4.59L15.17 15 12 18.17z"
            />
          } @else {
            <path
              d="M7.41 18.59L8.83 20 12 16.83 15.17 20l1.41-1.41L12 14l-4.59 4.59zm9.18-13.18L15.17 4 12 7.17 8.83 4 7.41 5.41 12 10l4.59-4.59z"
            />
          }
        </svg>
      </div>
    </ng-template>
  `,
})
export default class App {
  protected readonly dataSource = dataSource;
  protected readonly columns = columns;
  protected readonly defaultGroupBy = defaultGroupBy;

  private readonly groupCellTemplate =
    viewChild.required<TemplateRef<unknown>>('groupCell');

  protected readonly groupColumn: InfiniteTablePropGroupColumn<Developer> = {
    defaultWidth: 250,
    render: ({ rowInfo }) =>
      rowInfo.isGroupRow ? this.groupCellTemplate() : null,
  };
}
```

The `column.render` function can return a string, a `TemplateRef` (it gets the value as `$implicit` and the param's properties by name, eg `let-rowInfo="rowInfo"`) or a component (`renderComponent(...)`), which reads the same param with [`injectColumnCell`](https://infinite-table.com/docs/reference/hooks/index.md#useInfiniteColumnCell). To replace the whole cell, use [column.components.ColumnCell](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#columns.components.ColumnCell).

**Example: Column with custom render that uses useInfiniteColumnCell**

```ts
import { Component, computed } from '@angular/core';

import {
  DataSource,
  InfiniteTable,
  injectColumnCell,
  renderComponent,
} from '@infinite-table/infinite-angular';
import type { InfiniteTablePropColumns } from '@infinite-table/infinite-angular';

type Developer = {
  id: number;
  firstName: string;
  lastName: string;
  country: string;
  city: string;
  currency: string;
  preferredLanguage: string;
  stack: string;
  canDesign: 'yes' | 'no';
  hobby: string;
  salary: number;
  age: number;
};

const dataSource = () => {
  return fetch(process.env.NEXT_PUBLIC_BASE_URL + '/developers1k')
    .then((r) => r.json())
    .then((data: Developer[]) => data);
};

const EMOJIS: Record<string, string> = {
  photography: '📸',
  cooking: '👨🏻‍🍳',
  dancing: '💃',
  reading: '📚',
  sports: '⛹️',
};

@Component({
  selector: 'custom-cell',
  template: `<b>{{ emoji() }} + {{ label() }}</b>`,
})
class CustomCell {
  
  private readonly cell = injectColumnCell<Developer>();

  protected readonly emoji = computed(() => EMOJIS[this.cell().value] ?? '🤷');
  protected readonly label = computed(() =>
    this.cell().data?.stack === 'frontend' ? '⚛️' : '',
  );
}

const columns: InfiniteTablePropColumns<Developer> = {
  id: { field: 'id', maxWidth: 80 },
  firstName: { field: 'firstName' },
  hobby: {
    field: 'hobby',
    // we're not using the arg of the render function directly
    // but CustomCell uses `injectColumnCell()` to retrieve it instead
    render: () => renderComponent(CustomCell),
  },
};

@Component({
  selector: 'demo-root',
  imports: [DataSource, InfiniteTable],
  template: `
    <infinite-data-source primaryKey="id" [data]="dataSource">
      <infinite-table
        debugId="column-render-hooks-example"
        [columns]="columns"
        [columnDefaultWidth]="200"
      />
    </infinite-data-source>
  `,
})
export default class App {
  protected readonly dataSource = dataSource;
  protected readonly columns = columns;
}
```

### columns.renderFilterIcon

> Customizes the rendering of the filter icon for the column.

The `salary` column will show a bolded label when filtered.

The `firstName` column will show a custom filter icon when filtered.

**Example: Custom filter icons for salary and name columns**

```ts
import { Component, TemplateRef, viewChild } from '@angular/core';

import { DataSource, InfiniteTable } from '@infinite-table/infinite-angular';
import type {
  DataSourceData,
  DataSourcePropFilterValue,
  InfiniteTablePropColumns,
} from '@infinite-table/infinite-angular';

type Developer = {
  id: number;
  firstName: string;
  lastName: string;

  currency: string;
  preferredLanguage: string;
  stack: string;
  canDesign: 'yes' | 'no';

  salary: number;
};

const data: DataSourceData<Developer> = () => {
  return fetch(process.env.NEXT_PUBLIC_BASE_URL + `/developers1k-sql?`)
    .then((r) => r.json())
    .then((data: Developer[]) => data);
};

const domProps = {
  style: {
    height: '100%',
  },
};

@Component({
  selector: 'demo-root',
  imports: [DataSource, InfiniteTable],
  template: `
    <infinite-data-source
      [data]="data"
      primaryKey="id"
      [defaultFilterValue]="defaultFilterValue"
      [filterDelay]="0"
    >
      <infinite-table
        debugId="column-filter-icon-example"
        [domProps]="domProps"
        [columnDefaultWidth]="150"
        [columnMinWidth]="50"
        [columns]="columns"
      />
    </infinite-data-source>

    <ng-template #boldSalary>
      <b>Salary</b>
    </ng-template>
  `,
})
export default class App {
  protected readonly data = data;
  protected readonly domProps = domProps;
  protected readonly defaultFilterValue: DataSourcePropFilterValue<Developer> =
    [];

  private readonly boldSalaryTemplate =
    viewChild.required<TemplateRef<unknown>>('boldSalary');

  protected readonly columns: InfiniteTablePropColumns<Developer> = {
    id: {
      field: 'id',
      type: 'number',
      defaultWidth: 100,
    },
    salary: {
      field: 'salary',
      type: 'number',
      header: ({ filtered }) => {
        return filtered ? this.boldSalaryTemplate() : 'Salary';
      },

      renderFilterIcon: () => {
        return null;
      },
    },

    firstName: {
      field: 'firstName',
      renderFilterIcon: ({ filtered }) => {
        return filtered ? '🔥' : '';
      },
    },
    stack: { field: 'stack' },
    currency: { field: 'currency' },
  };
}
```

### columns.renderGroupIcon (`(cellContext) => Renderable`)

> Customizes the rendering of the collapse/expand group icon for group rows. The argument passed to the function is an object of type [`InfiniteTableColumnCellContextType`](https://infinite-table.com/docs/reference/type-definitions/index.md#InfiniteTableColumnCellContextType)

For actual content of group cells, see related [`columns.renderGroupValue`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#columns.renderGroupValue)

To understand how the rendering pipeline works, head over to the page on [Column rendering](https://infinite-table.com/angular/docs/learn/columns/column-rendering.md#rendering-pipeline).

**Example: Column with custom renderGroupIcon**

```ts
import { Component, TemplateRef, viewChild } from '@angular/core';

import {
  DataSource,
  InfiniteTable,
  renderTemplate,
} from '@infinite-table/infinite-angular';
import type {
  DataSourcePropGroupBy,
  InfiniteTablePropColumns,
} from '@infinite-table/infinite-angular';

type Developer = {
  id: number;
  firstName: string;
  lastName: string;
  country: string;
  city: string;
  currency: string;
  preferredLanguage: string;
  stack: string;
  canDesign: 'yes' | 'no';
  hobby: string;
  salary: number;
  age: number;
};

const dataSource = () => {
  return fetch(process.env.NEXT_PUBLIC_BASE_URL + '/developers1k')
    .then((r) => r.json())
    .then((data: Developer[]) => data);
};

const groupBy: DataSourcePropGroupBy<Developer> = [
  {
    field: 'country',
    column: {
      header: 'Country group',
      renderGroupValue: ({ value }) => `Country: ${value}`,
    },
  },
];

@Component({
  selector: 'demo-root',
  imports: [DataSource, InfiniteTable],
  template: `
    <infinite-data-source [data]="dataSource" primaryKey="id" [groupBy]="groupBy">
      <infinite-table
        debugId="column-renderGroupValueAndRenderLeafValue-example"
        [columns]="columns"
      />
    </infinite-data-source>

    
    <ng-template #leafValue let-value="value" let-rowInfo="rowInfo">
      <b>🎇 {{ value }} → {{ rowInfo.value }}</b>
    </ng-template>
  `,
})
export default class App {
  protected readonly dataSource = dataSource;
  protected readonly groupBy = groupBy;

  private readonly leafValueTemplate =
    viewChild.required<TemplateRef<unknown>>('leafValue');

  protected readonly columns: InfiniteTablePropColumns<Developer> = {
    id: { field: 'id', defaultWidth: 80 },
    stack: {
      field: 'stack',
      renderGroupValue: ({ rowInfo, value }) => {
        // value is undefined in the country group rows
        return `${value ?? ''} → ${rowInfo.value} stuff`;
      },
      renderLeafValue: ({ value, rowInfo }) => {
        return renderTemplate(this.leafValueTemplate(), { value, rowInfo });
      },
    },
    firstName: {
      field: 'firstName',
    },

    preferredLanguage: { field: 'preferredLanguage' },
  };
}
```

### columns.renderMenuIcon (`boolean|(cellContext)=> ReactNode`)

> Allows customization of the context menu icon.

Use this prop to customize the context icon for the current column. Specify `false` for no context menu icon.

Use a function to render a custom icon. The function is called with an object that has the following properties:

- `column`
- `columnApi` - an API object for controlling the column programatically (toggle sort, toggle column context menu, etc)

In this example, the currency and preferredLanguage columns have a custom icon for triggering the column context menu.

In addition, the `preferredLanguage` column has a custom header that shows a button for triggering the column context menu.

**Example: Custom menu icons and custom menu items**

```ts
import { Component, TemplateRef, viewChild } from '@angular/core';

import {
  DataSource,
  InfiniteTable,
  renderTemplate,
} from '@infinite-table/infinite-angular';
import type {
  InfiniteTablePropColumns,
  InfiniteTablePropGetColumnMenuItems,
} from '@infinite-table/infinite-angular';

type Developer = {
  id: number;
  firstName: string;
  lastName: string;
  country: string;
  city: string;
  currency: string;
  preferredLanguage: string;
  stack: string;
  canDesign: 'yes' | 'no';
  hobby: string;
  salary: number;
  age: number;
};

const dataSource = () => {
  return fetch(process.env.NEXT_PUBLIC_BASE_URL + '/developers1k')
    .then((r) => r.json())
    .then((data: Developer[]) => data);
};

const getColumnMenuItems: InfiniteTablePropGetColumnMenuItems<Developer> = (
  items,
  { column },
) => {
  if (column.id === 'firstName') {
    // you can adjust the default items for a specific column
    items.splice(0, 0, {
      key: 'firstName',
      label: 'First name menu item',
      onAction: () => {
        console.log('Hey there!');
      },
    });
  }

  items.push(
    {
      key: 'hello',
      label: 'Hello World',
      onAction: () => {
        alert('Hello World from column ' + column.id);
      },
    },
    {
      key: 'translate',
      label: 'Translate',
      menu: {
        items: [
          {
            key: 'translateToEnglish',
            label: 'English',
            onAction: () => {
              console.log('Translate to English');
            },
          },
          {
            key: 'translateToFrench',
            label: 'French',
            onAction: () => {
              console.log('Translate to French');
            },
          },
        ],
      },
    },
  );
  return items;
};

@Component({
  selector: 'demo-root',
  imports: [DataSource, InfiniteTable],
  template: `
    <infinite-data-source primaryKey="id" [data]="dataSource">
      <infinite-table
        debugId="getColumnMenuItems-example"
        [columnHeaderHeight]="70"
        [columns]="columns"
        [getColumnMenuItems]="getColumnMenuItems"
      />
    </infinite-data-source>

    <!-- custom menu icon -->
    <ng-template #globe>
      <div>🌎</div>
    </ng-template>

    
    <ng-template #languageHeader let-columnApi="columnApi">
      Preferred Language
      <!-- stop the propagation of pointerdown, so a click on the button doesn't sort the column, and of mousedown, so the menu is not closed automatically: the button toggles it -->
      <button
        style="border: 1px solid magenta; margin: 2px"
        (pointerdown)="$event.stopPropagation()"
        (mousedown)="
          $event.stopPropagation(); columnApi.toggleContextMenu($event.target)
        "
      >
        Toggle menu
      </button>
    </ng-template>
  `,
})
export default class App {
  protected readonly dataSource = dataSource;
  protected readonly getColumnMenuItems = getColumnMenuItems;

  private readonly globeTemplate =
    viewChild.required<TemplateRef<unknown>>('globe');
  private readonly languageHeaderTemplate =
    viewChild.required<TemplateRef<unknown>>('languageHeader');

  protected readonly columns: InfiniteTablePropColumns<Developer> = {
    currency: {
      field: 'currency',

      // custom menu icon
      renderMenuIcon: () => this.globeTemplate(),
    },

    preferredLanguage: {
      field: 'preferredLanguage',
      defaultWidth: 350,
      header: ({ columnApi, renderLocation }) => {
        // if we're inside the column menu with all columns, return only the col name
        if (renderLocation === 'column-menu') {
          return 'Preferred Language';
        }

        // but for the real column header
        // return this custom content
        return renderTemplate(this.languageHeaderTemplate(), { columnApi });
      },

      // custom menu icon
      renderMenuIcon: () => this.globeTemplate(),
    },
    salary: {
      field: 'salary',
      // hide the menu icon
      renderMenuIcon: false,
    },
    country: {
      field: 'country',
    },
    id: { field: 'id', defaultWidth: 80, renderMenuIcon: false },
    firstName: {
      field: 'firstName',
    },
  };
}
```

### columns.renderSelectionCheckBox (`boolean | ({ data, rowSelected: boolean | null, selectRow, deselectRow, ... })`)

> Specifies that the current column will have a selection checkbox - if a function is provided, will be used to customizes the rendering of the checkbox rendered for selection.

See related [`[(rowSelection)]`](https://infinite-table.com/angular/docs/reference/datasource-props/index.md#rowSelection).

If `true` is provided, the default selection checkbox will be rendered. When a function is provided, it will be used for rendering the checkbox for selection.

`rowSelected` property in the function parameter can be either `boolean` or `null`. The `null` value is used for groups with indeterminate state, meaning the group has some children selected, but not all of them.

To understand how the rendering pipeline works, head over to the page on [Column rendering](https://infinite-table.com/angular/docs/learn/columns/column-rendering.md#rendering-pipeline).

This example shows how you can use the default selection checkbox and decorate it.

**Example: Column with custom renderSelectionCheckBox**

```ts
import { Component, TemplateRef, viewChild } from '@angular/core';

import {
  DataSource,
  InfiniteRender,
  InfiniteTable,
  renderTemplate,
} from '@infinite-table/infinite-angular';
import type {
  DataSourceProps,
  InfiniteTablePropColumns,
  InfiniteTableProps,
} from '@infinite-table/infinite-angular';

const columns: InfiniteTablePropColumns<Developer> = {
  country: {
    field: 'country',
  },
  firstName: {
    field: 'firstName',
    defaultHiddenWhenGroupedBy: '*',
  },
  stack: {
    field: 'stack',
    renderGroupValue: ({ value }) => `Stack: ${value || ''}`,
  },
  age: { field: 'age' },
  id: { field: 'id' },
  preferredLanguage: {
    field: 'preferredLanguage',
    renderGroupValue: ({ value }) => `Lang: ${value || ''}`,
  },
  canDesign: {
    field: 'canDesign',
    renderGroupValue: ({ value }) => `Can design: ${value || ''}`,
  },
};

const defaultGroupBy: DataSourceProps<Developer>['groupBy'] = [
  {
    field: 'canDesign',
  },
  {
    field: 'stack',
  },
  {
    field: 'preferredLanguage',
  },
];

const domProps = {
  style: {
    flex: 1,
    minHeight: 500,
  },
};

@Component({
  selector: 'demo-root',
  imports: [DataSource, InfiniteTable, InfiniteRender],
  template: `
    <infinite-data-source
      [data]="dataSource"
      [groupBy]="defaultGroupBy"
      selectionMode="multi-row"
      primaryKey="id"
    >
      <infinite-table
        debugId="column-renderSelectionCheckBox-example"
        [columns]="columns"
        [domProps]="domProps"
        [groupColumn]="groupColumn"
        [columnDefaultWidth]="150"
      />
    </infinite-data-source>

    
    <ng-template #selection let-selectionCheckBox="selectionCheckBox">
      <b>[<ng-container [infiniteRender]="selectionCheckBox" />]</b>
    </ng-template>
  `,
})
export default class App {
  protected readonly dataSource = dataSource;
  protected readonly columns = columns;
  protected readonly defaultGroupBy = defaultGroupBy;
  protected readonly domProps = domProps;

  private readonly selectionTemplate =
    viewChild.required<TemplateRef<unknown>>('selection');

  protected readonly groupColumn: InfiniteTableProps<Developer>['groupColumn'] =
    {
      field: 'firstName',
      renderSelectionCheckBox: ({ renderBag }) => {
        // render the default value and decorate it
        return renderTemplate(this.selectionTemplate(), {
          selectionCheckBox: renderBag.selectionCheckBox,
        });
      },
      defaultWidth: 300,
    };
}

const dataSource = () => {
  return fetch(process.env.NEXT_PUBLIC_BASE_URL + '/developers100')
    .then((r) => r.json())
    .then((data: Developer[]) => data);
};

type Developer = {
  id: number;
  firstName: string;
  lastName: string;
  country: string;
  city: string;
  currency: string;
  email: string;
  preferredLanguage: string;
  stack: string;
  canDesign: 'yes' | 'no';
  hobby: string;
  salary: number;
  age: number;
};
```

### columns.renderGroupValue (`({ data, rowInfo, column, renderBag, rowIndex, ... })`)

> Customizes the rendering of a group column content, but only for group rows.

This prop is different from [`columns.render`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#columns.render), [`columns.renderValue`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#columns.renderValue), as it is only called for group rows.

This function prop is called with a parameter - the `value` property of this parameter is not useful for group rows (of non-group columns), as it refers to the current data item, which is a group item, not a normal data item. Instead, use `rowInfo.value`, as that's the current group row value.

See related [`columns.renderGroupIcon`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#columns.renderGroupIcon) for customizing the collapse/expand group icon.
See related [`columns.renderLeafValue`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#columns.renderLeafValue) for customizing the value for non-group rows in a group column.

**Example: Column with custom renderGroupValue**

```ts
import { Component, TemplateRef, viewChild } from '@angular/core';

import {
  DataSource,
  InfiniteTable,
  renderTemplate,
} from '@infinite-table/infinite-angular';
import type {
  DataSourcePropGroupBy,
  InfiniteTablePropColumns,
} from '@infinite-table/infinite-angular';

type Developer = {
  id: number;
  firstName: string;
  lastName: string;
  country: string;
  city: string;
  currency: string;
  preferredLanguage: string;
  stack: string;
  canDesign: 'yes' | 'no';
  hobby: string;
  salary: number;
  age: number;
};

const dataSource = () => {
  return fetch(process.env.NEXT_PUBLIC_BASE_URL + '/developers1k')
    .then((r) => r.json())
    .then((data: Developer[]) => data);
};

const groupBy: DataSourcePropGroupBy<Developer> = [
  {
    field: 'country',
    column: {
      header: 'Country group',
      renderGroupValue: ({ value }) => `Country: ${value}`,
    },
  },
];

@Component({
  selector: 'demo-root',
  imports: [DataSource, InfiniteTable],
  template: `
    <infinite-data-source [data]="dataSource" primaryKey="id" [groupBy]="groupBy">
      <infinite-table
        debugId="column-renderGroupValueAndRenderLeafValue-example"
        [columns]="columns"
      />
    </infinite-data-source>

    
    <ng-template #leafValue let-value="value" let-rowInfo="rowInfo">
      <b>🎇 {{ value }} → {{ rowInfo.value }}</b>
    </ng-template>
  `,
})
export default class App {
  protected readonly dataSource = dataSource;
  protected readonly groupBy = groupBy;

  private readonly leafValueTemplate =
    viewChild.required<TemplateRef<unknown>>('leafValue');

  protected readonly columns: InfiniteTablePropColumns<Developer> = {
    id: { field: 'id', defaultWidth: 80 },
    stack: {
      field: 'stack',
      renderGroupValue: ({ rowInfo, value }) => {
        // value is undefined in the country group rows
        return `${value ?? ''} → ${rowInfo.value} stuff`;
      },
      renderLeafValue: ({ value, rowInfo }) => {
        return renderTemplate(this.leafValueTemplate(), { value, rowInfo });
      },
    },
    firstName: {
      field: 'firstName',
    },

    preferredLanguage: { field: 'preferredLanguage' },
  };
}
```

### columns.renderLeafValue (`({ data, rowInfo, column, renderBag, rowIndex, ... })`)

> Customizes the rendering of the group column content, but only for non-group rows.

See related [`columns.renderGroupValue`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#columns.renderGroupValue) for customizing the value for group rows in a group column.

**Example: Column with custom renderLeafValue**

```ts
import { Component, TemplateRef, viewChild } from '@angular/core';

import {
  DataSource,
  InfiniteTable,
  renderTemplate,
} from '@infinite-table/infinite-angular';
import type {
  DataSourcePropGroupBy,
  InfiniteTablePropColumns,
} from '@infinite-table/infinite-angular';

type Developer = {
  id: number;
  firstName: string;
  lastName: string;
  country: string;
  city: string;
  currency: string;
  preferredLanguage: string;
  stack: string;
  canDesign: 'yes' | 'no';
  hobby: string;
  salary: number;
  age: number;
};

const dataSource = () => {
  return fetch(process.env.NEXT_PUBLIC_BASE_URL + '/developers1k')
    .then((r) => r.json())
    .then((data: Developer[]) => data);
};

const groupBy: DataSourcePropGroupBy<Developer> = [
  {
    field: 'country',
    column: {
      header: 'Country group',
      renderGroupValue: ({ value }) => `Country: ${value}`,
    },
  },
];

@Component({
  selector: 'demo-root',
  imports: [DataSource, InfiniteTable],
  template: `
    <infinite-data-source [data]="dataSource" primaryKey="id" [groupBy]="groupBy">
      <infinite-table
        debugId="column-renderGroupValueAndRenderLeafValue-example"
        [columns]="columns"
      />
    </infinite-data-source>

    
    <ng-template #leafValue let-value="value" let-rowInfo="rowInfo">
      <b>🎇 {{ value }} → {{ rowInfo.value }}</b>
    </ng-template>
  `,
})
export default class App {
  protected readonly dataSource = dataSource;
  protected readonly groupBy = groupBy;

  private readonly leafValueTemplate =
    viewChild.required<TemplateRef<unknown>>('leafValue');

  protected readonly columns: InfiniteTablePropColumns<Developer> = {
    id: { field: 'id', defaultWidth: 80 },
    stack: {
      field: 'stack',
      renderGroupValue: ({ rowInfo, value }) => {
        // value is undefined in the country group rows
        return `${value ?? ''} → ${rowInfo.value} stuff`;
      },
      renderLeafValue: ({ value, rowInfo }) => {
        return renderTemplate(this.leafValueTemplate(), { value, rowInfo });
      },
    },
    firstName: {
      field: 'firstName',
    },

    preferredLanguage: { field: 'preferredLanguage' },
  };
}
```

### columns.renderValue (`(cellContext) => Renderable`)

> Customizes the rendering of the column content. The argument passed to the function is an object of type [`InfiniteTableColumnCellContextType`](https://infinite-table.com/docs/reference/type-definitions/index.md#InfiniteTableColumnCellContextType)

See related [`columns.render`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#columns.render), [`columns.renderGroupValue`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#columns.renderGroupValue)

The difference between [`columns.renderValue`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#columns.renderValue) and [`columns.render`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#columns.render) is only for special columns (for now, only group columns are special columns, but more will come) when `InfiniteTable` renders additional content inside the column (eg: collapse/expand tool for group rows). The [`columns.render`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#columns.render) function allows you to override the additional content. So if you specify this function, it's up to you to render whatever content, including the collapse/expand tool.

Note that for customizing the collapse/expand tool, you can use specify `renderGroupIcon` function on the group column.

To understand how the rendering pipeline works, head over to the page on [Column rendering](https://infinite-table.com/angular/docs/learn/columns/column-rendering.md#rendering-pipeline).

The [renderValue](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#columns.renderValue) and [render](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#columns.render) functions are called with an object that has the following properties:

- data - the data object (of type `DATA_TYPE | Partial<DATA_TYPE> | null`) for the row.
- rowInfo - very useful information about the current row. See [Using RowInfo](https://infinite-table.com/angular/docs/learn/rows/using-row-info.md) for more details.
- renderBag - read more about this in the docs for [Column rendering pipeline](https://infinite-table.com/angular/docs/learn/columns/column-rendering.md#rendering-pipeline)

**Example: Column with custom renderValue**

```ts
import { Component, TemplateRef, viewChild } from '@angular/core';

import { DataSource, InfiniteTable } from '@infinite-table/infinite-angular';
import type {
  DataSourceGroupBy,
  InfiniteTableColumnRenderValueParam,
  InfiniteTablePropColumns,
  InfiniteTablePropGroupColumn,
} from '@infinite-table/infinite-angular';

type Developer = {
  id: number;
  firstName: string;
  lastName: string;
  country: string;
  city: string;
  currency: string;
  preferredLanguage: string;
  stack: string;
  canDesign: 'yes' | 'no';
  hobby: string;
  salary: number;
  age: number;
};

const dataSource = () => {
  return fetch(process.env.NEXT_PUBLIC_BASE_URL + '/developers1k')
    .then((r) => r.json())
    .then((data: Developer[]) => data);
};

@Component({
  selector: 'demo-root',
  imports: [DataSource, InfiniteTable],
  template: `
    <infinite-data-source
      primaryKey="id"
      [data]="dataSource"
      [defaultGroupBy]="defaultGroupBy"
    >
      <infinite-table
        debugId="column-renderValue-example"
        [groupColumn]="groupColumn"
        [columns]="columns"
        [columnDefaultWidth]="200"
      />
    </infinite-data-source>

    
    <ng-template #stack let-data="data">
      <b>🎇 {{ data?.stack }}</b>
    </ng-template>

    <ng-template #groupedBy let-rowInfo="rowInfo">
      Grouped by <b>{{ rowInfo.value }}</b>
    </ng-template>
  `,
})
export default class App {
  protected readonly dataSource = dataSource;

  private readonly stackTemplate =
    viewChild.required<TemplateRef<unknown>>('stack');
  private readonly groupedByTemplate =
    viewChild.required<TemplateRef<unknown>>('groupedBy');

  // the columns are a plain field: a template goes in through a function
  protected readonly columns: InfiniteTablePropColumns<Developer> = {
    id: { field: 'id', defaultWidth: 80 },
    stack: {
      field: 'stack',
      renderValue: ({ rowInfo }) => {
        if (rowInfo.isGroupRow) {
          return `${rowInfo.value} stuff`;
        }

        return this.stackTemplate();
      },
    },
    firstName: {
      field: 'firstName',
    },

    preferredLanguage: { field: 'preferredLanguage' },
  };

  protected readonly defaultGroupBy: DataSourceGroupBy<Developer>[] = [
    { field: 'stack' },
  ];

  protected readonly groupColumn: InfiniteTablePropGroupColumn<Developer> = {
    defaultWidth: 250,

    renderValue: ({
      rowInfo,
    }: InfiniteTableColumnRenderValueParam<Developer>) => {
      if (rowInfo.isGroupRow) {
        return this.groupedByTemplate();
      }
      return null;
    },
  };
}
```

The `column.renderValue` function can return a string, a `TemplateRef` (it gets the value as `$implicit` and the param's properties by name, eg `let-rowInfo="rowInfo"`) or a component (`renderComponent(...)`), which reads the same param with [`injectColumnCell`](https://infinite-table.com/docs/reference/hooks/index.md#useInfiniteColumnCell). To replace the whole cell, use [column.components.ColumnCell](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#columns.components.ColumnCell).

**Example: Using a sparkline component**

```ts
import { Component, computed, input } from '@angular/core';

import {
  DataSource,
  InfiniteTable,
  renderComponent,
} from '@infinite-table/infinite-angular';
import type { InfiniteTableColumn } from '@infinite-table/infinite-angular';

type Employee = {
  id: number;
  companyName: string;
  companySize: string;
  firstName: string;
  lastName: string;
  country: string;
  countryCode: string;
  city: string;
  bugFixes: number[];
  streetName: string;
  streetPrefix: string;
  streetNo: string;
  department: string;
  team: string;
  salary: number;
  currency: number;
  age: number;
  email: string;
};

// the drawing width - the svg is stretched to the cell width
const WIDTH = 240;
const MARGIN = 2;

type Point = { x: number; y: number };

const toPoints = (points: Point[]) =>
  points.map(({ x, y }) => `${x},${y}`).join(' ');

/**
 * A small inline-SVG sparkline: a line over the values,
 * with the area below it lightly filled
 */
@Component({
  selector: 'sparkline',
  host: { style: 'display: contents' },
  template: `
    <svg
      style="width: 100%"
      [attr.viewBox]="viewBox()"
      preserveAspectRatio="none"
    >
      <polyline
        [attr.points]="areaPoints()"
        [attr.fill]="color()"
        fill-opacity="0.1"
        stroke="none"
      />
      <polyline
        [attr.points]="linePoints()"
        [attr.stroke]="color()"
        stroke-width="1"
        stroke-linejoin="round"
        stroke-linecap="round"
        fill="none"
      />
    </svg>
  `,
})
class Sparkline {
  readonly values = input.required<number[]>();
  readonly color = input('slategray');
  readonly height = input(60);

  protected readonly viewBox = computed(() => `0 0 ${WIDTH} ${this.height()}`);

  private readonly points = computed((): Point[] => {
    const values = this.values();
    const height = this.height();
    const min = Math.min(...values);
    const max = Math.max(...values);
    const xStep = (WIDTH - MARGIN * 2) / Math.max(values.length - 1, 1);
    const yStep = (height - MARGIN * 2) / (max - min || 2);

    return values.map((value, index) => ({
      x: index * xStep + MARGIN,
      y: (max === min ? 1 : max - value) * yStep + MARGIN,
    }));
  });

  protected readonly linePoints = computed(() => toPoints(this.points()));

  // the line, closed along the bottom edge
  protected readonly areaPoints = computed(() => {
    const points = this.points();
    const bottom = this.height() - MARGIN;
    return toPoints([
      ...points,
      { x: points[points.length - 1].x, y: bottom },
      { x: MARGIN, y: bottom },
      { x: MARGIN, y: points[0].y },
    ]);
  });
}

const columns: Record<string, InfiniteTableColumn<Employee>> = {
  firstName: {
    field: 'firstName',
    header: 'First Name',
  },
  country: {
    field: 'country',
    header: 'Country',
    columnGroup: 'location',
  },
  bugFixes: {
    field: 'bugFixes',
    header: 'Bug Fixes',
    defaultWidth: 300,
    renderValue: ({ value, data }) => {
      const color =
        data?.department === 'IT' || data?.department === 'Management'
          ? 'tomato'
          : '#253e56';
      return renderComponent(Sparkline, {
        inputs: { values: value, color, height: 30 },
      });
    },
  },
  city: {
    field: 'city',
    header: 'City',
    columnGroup: 'address',
  },
  salary: {
    field: 'salary',
    type: 'number',
    header: 'Salary',
  },
  department: {
    field: 'department',
    header: 'Department',
  },
  team: {
    field: 'team',
    header: 'Team',
  },
};

const dataSource = () => {
  return fetch(process.env.NEXT_PUBLIC_BASE_URL + '/employees10k')
    .then((r) => r.json())
    .then((data: Employee[]) => {
      return data.map((employee) => {
        return {
          ...employee,
          bugFixes: [...Array(10)].map(() => Math.round(Math.random() * 100)),
        };
      });
    });
};

@Component({
  selector: 'demo-root',
  imports: [DataSource, InfiniteTable],
  template: `
    <infinite-data-source [data]="dataSource" primaryKey="id">
      <infinite-table
        debugId="using-sparklines-example"
        [columns]="columns"
        [columnDefaultWidth]="150"
      />
    </infinite-data-source>
  `,
})
export default class App {
  protected readonly dataSource = dataSource;
  protected readonly columns = columns;
}
```

### columns.repaintCellsKey (`string|number|object|(params: InfiniteTablePropRepaintCellsKeyFnParams) => any`)

> Forces the cells of this column to re-render when their row did not change, but something they render depends on did.

Same as the table-level [`repaintCellsKey`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#repaintCellsKey), but only for the cells of this column. When both are specified, the column-level key wins for the cells of this column.

Typical use: a column whose [`columns.render`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#columns.render) or [`columns.valueGetter`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#columns.valueGetter) reads other rows (a group average, a running total, a cross-row lookup). Return the derived value from the function, and the cells repaint exactly when that value changes:

```tsx
const columns: InfiniteTablePropColumns<Sale> = {
  segmentAverage: {
    header: 'Segment avg',
    repaintCellsKey: ({ rowInfo, dataSourceState }) =>
      averageFor(dataSourceState.originalDataArray, rowInfo.data?.segment),
    render: ({ rowInfo, dataSourceApi }) =>
      averageFor(dataSourceApi.getOriginalDataArray(), rowInfo.data?.segment),
  },
};
```

Scanning the whole data array in `repaintCellsKey` and again in `render` - for every cell, on every data change - is **not** a performant way to compute averages or other aggregations. It's used here only because it keeps the demo short. In a real app, compute the aggregations once per data change (eg. in a memoized map keyed by a specific field, or have it computed for you automatically via [`aggregationReducers`](https://infinite-table.com/angular/docs/reference/datasource-props/index.md#aggregationReducers) when grouping) and have both `repaintCellsKey` and `render` read from that.

See [`repaintCellsKey`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#repaintCellsKey) for details on the string/number/object and function forms and on the parameter the function is called with.

### columns.resizable (`boolean`)

> Specifies if the current column is resizable or not.

By default, all columns are resizable, since [`resizableColumns`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#resizableColumns) defaults to `true`.

### columns.rowspan (`({ rowInfo, data, rowIndex, column }) => number`)

> Specifies the rowspan for cells on the current column.

The default rowspan for a column cell is 1. If you want to span multiple rows, return a value that is greater than 1.

This function is called with an object that has the following properties:

- column - the current column
- data - the current data
- rowInfo - information about the current row

The `rowInfo` object contains information about grouping (if this row is a group row, the collapsed state, etc), parent groups, children of the current row (if it's a row group), etc. See [Using RowInfo](https://infinite-table.com/angular/docs/learn/rows/using-row-info.md) for more details.

```ts
import { Component } from '@angular/core';

import { DataSource, InfiniteTable } from '@infinite-table/infinite-angular';
import type {
  DataSourceGroupBy,
  InfiniteTableGroupColumnBase,
  InfiniteTablePropColumns,
} from '@infinite-table/infinite-angular';

type Developer = {
  id: number;
  firstName: string;
  lastName: string;
  country: string;
  city: string;
  currency: string;
  preferredLanguage: string;
  stack: string;
  canDesign: 'yes' | 'no';
  hobby: string;
  salary: number;
  age: number;
};

const columns: InfiniteTablePropColumns<Developer> = {
  id: { field: 'id' },
  firstName: { field: 'firstName' },
  preferredLanguage: {
    field: 'preferredLanguage',
  },
  stack: { field: 'stack' },
  country: { field: 'country' },
  canDesign: { field: 'canDesign' },
  hobby: { field: 'hobby' },

  city: {
    field: 'city',
  },
  age: { field: 'age' },
  salary: {
    field: 'salary',
    type: 'number',
  },
  currency: { field: 'currency' },
};

const defaultGroupBy: DataSourceGroupBy<Developer>[] = [
  { field: 'stack' },
  { field: 'preferredLanguage' },
  {
    field: 'country',
    column: {
      rowspan: ({ rowInfo }) => {
        const rowspan =
          rowInfo.isGroupRow && rowInfo.groupNesting === 3 && !rowInfo.collapsed
            ? (rowInfo.deepRowInfoArray?.length || 0) + 1
            : 1;

        return rowspan;
      },
    } as InfiniteTableGroupColumnBase<Developer>,
  },
];

@Component({
  selector: 'demo-root',
  imports: [DataSource, InfiniteTable],
  template: `
    <infinite-data-source
      [data]="dataSource"
      [defaultGroupBy]="defaultGroupBy"
      primaryKey="id"
    >
      <infinite-table
        debugId="column-rowspan-example"
        [columns]="columns"
        [columnDefaultWidth]="250"
      />
    </infinite-data-source>
  `,
})
export default class App {
  protected readonly dataSource = dataSource;
  protected readonly columns = columns;
  protected readonly defaultGroupBy = defaultGroupBy;
}

const dataSource = () => {
  return fetch(process.env.NEXT_PUBLIC_BASE_URL + '/developers1k')
    .then((r) => r.json())
    .then((data: Developer[]) => data);
};
```

### columns.shouldAcceptEdit (`(params) => boolean|Error|Promise<boolean|Error>`)

> Function specified for the column, that determines whether to accept an edit or not.

This function is called when the user wants to finish an edit. The function is used to decide whether an edit is accepted or rejected.

<p>When the global [`shouldAcceptEdit`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#shouldAcceptEdit) prop is specified, this is no longer called, and instead the global one is called.</p>
<p>If you define the global [`shouldAcceptEdit`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#shouldAcceptEdit) and still want to use the column-level function, you can call the column-level function from the global one.</p>

The function is called with an object that has the following properties:

- `value` - the value that the user wants to persist via the cell editor
- `initialValue` - the initial value of the cell (the value that was displayed before editing started). This is the value resulting after [`columns.valueFormatter`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#columns.valueFormatter) and [`columns.renderValue`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#columns.renderValue) have been applied)
- `rawValue` - the initial value of the cell, but before any formatting and custom rendering has been applied. This is either the field value from the current data object, or the result of the column [valueGetter](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#columns.valueGetter) function.
- `data` - the current data object
- `rowInfo` - the row info object that underlies the row
- `column` - the current column on which editing is invoked
- `api` - a reference to the [InfiniteTable API](https://infinite-table.com/docs/reference/api/index.md)
- `dataSourceApi` - - a reference to the [DataSource API](https://infinite-table.com/angular/docs/reference/datasource-api/index.md)

Try editing the `salary` column. In the editor you can write whatever, but the column will only accept edits that are valid numbers.

```ts
import { Component } from '@angular/core';

import { DataSource, InfiniteTable } from '@infinite-table/infinite-angular';
import type { InfiniteTablePropColumns } from '@infinite-table/infinite-angular';

type Developer = {
  id: number;
  firstName: string;
  currency: string;
  stack: string;
  hobby: string;
  salary: string;
};
const dataSource: Developer[] = [
  {
    id: 1,
    firstName: 'John',
    currency: 'USD',
    stack: 'frontend',
    hobby: 'gaming',
    salary: 'USD 1000',
  },
  {
    id: 2,
    firstName: 'Jane',
    currency: 'EUR',
    stack: 'backend',
    hobby: 'reading',
    salary: 'EUR 2000',
  },
  {
    id: 3,
    firstName: 'Jack',
    currency: 'GBP',
    stack: 'frontend',
    hobby: 'gaming',
    salary: 'GBP 3000',
  },
  {
    id: 4,
    firstName: 'Jill',
    currency: 'USD',
    stack: 'backend',
    hobby: 'reading',
    salary: 'USD 4000',
  },
];

const columns: InfiniteTablePropColumns<Developer> = {
  id: { field: 'id', defaultWidth: 80, defaultEditable: false },

  salary: {
    defaultWidth: 320,
    field: 'salary',
    header: 'Salary - edit accepts numbers only',
    style: { color: 'tomato' },
    getValueToEdit: ({ value }) => {
      return parseInt(value.substr(4), 10);
    },
    getValueToPersist: ({ value, data }) => {
      return `${data!.currency} ${parseInt(value, 10)}`;
    },
    shouldAcceptEdit: ({ value }) => {
      return parseInt(value, 10) == value;
    },
  },

  firstName: {
    field: 'firstName',
    header: 'Name',
  },
  currency: {
    field: 'currency',
    header: 'Currency',
  },
};

@Component({
  selector: 'demo-root',
  imports: [DataSource, InfiniteTable],
  template: `
    <infinite-data-source primaryKey="id" [data]="dataSource">
      <infinite-table
        debugId="inline-editing-custom-edit-value-example"
        [columns]="columns"
        [columnDefaultEditable]="true"
      />
    </infinite-data-source>
  `,
})
export default class App {
  protected readonly dataSource = dataSource;
  protected readonly columns = columns;
}
```

### columns.sortable (`boolean`)

> Specifies the sorting behavior for the current column. Overrides the global [`sortable`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#sortable) prop.

Use this column property in order to explicitly make the column sortable or not sortable. If not specified, the sortable prop from the column type ([`columnTypes.sortable`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#columnTypes.sortable)) will be used. If that is not specified either, the global [`sortable`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#sortable) prop will be used.

### columns.sortType (`string | string[]`)

> Specifies the sort type for the column. See related [`sortTypes`](https://infinite-table.com/angular/docs/reference/datasource-props/index.md#sortTypes)

For local sorting, the sort order for a column is determined by the specified `sortType`.

- if no `sortType` is specified, the [column.dataType](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#columns.dataType) will be used as the `sortType`
- if no `sortType` or `dataType` is specified, it will default to the [`columns.type`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#columns.type) value (if an array, the first item will be used).
- if none of those are specified `"string"` is used

The value of this prop (as specified, or as computed by the steps described above) should be a key from the [`sortTypes`](https://infinite-table.com/angular/docs/reference/datasource-props/index.md#sortTypes) object.

**Example: Custom sort by color - magenta will come first**

```ts
import { Component } from '@angular/core';

import { DataSource, InfiniteTable } from '@infinite-table/infinite-angular';
import type { InfiniteTableColumn } from '@infinite-table/infinite-angular';

type CarSale = {
  id: number;

  make: string;
  model: string;
  year: number;

  sales: number;
  color: string;
};

const carsales: CarSale[] = [
  {
    make: 'Volkswagen',
    model: 'GTI',
    year: 2009,
    sales: 6,
    color: 'red',
    id: 0,
  },
  {
    make: 'Honda',
    model: 'Element 2WD',
    year: 2009,
    sales: 739,
    color: 'red',
    id: 1,
  },
  {
    make: 'Acura',
    model: 'RDX 4WD',
    year: 2008,
    sales: 2,
    color: 'magenta',
    id: 2,
  },
  {
    make: 'Honda',
    model: 'Fit',
    year: 2009,
    sales: 211,
    color: 'blue',
    id: 3,
  },
  {
    make: 'Mazda',
    model: '6',
    year: 2009,
    sales: 31,
    color: 'blue',

    id: 4,
  },
  {
    make: 'Acura',
    model: 'TSX',
    year: 2009,
    sales: 14,
    color: 'yellow',
    id: 5,
  },
  {
    make: 'Acura',
    model: 'TSX',
    year: 2010,
    sales: 14,
    color: 'red',
    id: 6,
  },
  {
    make: 'Audi',
    model: 'A3',
    year: 2009,
    sales: 2,
    color: 'magenta',
    id: 7,
  },
];

const columns: Record<string, InfiniteTableColumn<CarSale>> = {
  color: { field: 'color', sortType: 'color' },
  make: { field: 'make' },
  model: { field: 'model' },

  sales: {
    field: 'sales',
    sortType: 'number',
  },
  year: {
    field: 'year',
    sortType: 'number',
  },
};
const newSortTypes = {
  color: (one: string, two: string) => {
    if (one === 'magenta') {
      // magenta comes first
      return -1;
    }
    if (two === 'magenta') {
      // magenta comes first
      return 1;
    }
    return one.localeCompare(two);
  },
};

@Component({
  selector: 'demo-root',
  imports: [DataSource, InfiniteTable],
  template: `
    <infinite-data-source
      [data]="carsales"
      primaryKey="id"
      [defaultSortInfo]="{
        field: 'color',
        dir: 1,
        type: 'color',
      }"
      [sortTypes]="newSortTypes"
    >
      <infinite-table debugId="sortTypes-example" [columns]="columns" />
    </infinite-data-source>
  `,
})
export default class App {
  protected readonly carsales = carsales;
  protected readonly columns = columns;
  protected readonly newSortTypes = newSortTypes;
}
```

For group columns (and more specifically, when [`groupRenderStrategy`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#groupRenderStrategy) is `single-column`), the `sortType` should be a `string[]`, each item in the array corresponding to an item in [`[(groupBy)]`](https://infinite-table.com/angular/docs/reference/datasource-props/index.md#groupBy) of the `<DataSource />`. This is especially useful when there are no corresponding columns for the `groupBy` fields. In this case, `InfiniteTable` can't know the type of sorting those fields will require, so you have to provide it yourself via the `column.sortType`.

### columns.style (`CSSProperties | (param: InfiniteTableColumnStyleFnParams) => CSSProperties`)

> Controls styling for the column. Can be a style object or a function returning a style object.

If defined as a function, it accepts an object as a parameter (of type [`InfiniteTableColumnStylingFnParams`](https://infinite-table.com/docs/reference/type-definitions/index.md#InfiniteTableColumnStylingFnParams)), which has the following properties:

- `column` - the current column where the style is being applied
- `data` - the data object for the current row. The type of this object is `DATA_TYPE | Partial<DATA_TYPE> | null`. For regular rows, it will be of type `DATA_TYPE`, while for group rows it will be `Partial<DATA_TYPE>`. For rows not yet loaded (because of batching being used), it will be `null`.
- `rowInfo` - the information about the current row - see [Using RowInfo](https://infinite-table.com/angular/docs/learn/rows/using-row-info.md) for more details.
- `value` - the underlying value of the current cell - will generally be `data[column.field]`, if the column is bound to a `field` property
- ... and more, see [`InfiniteTableColumnStylingFnParams`](https://infinite-table.com/docs/reference/type-definitions/index.md#InfiniteTableColumnStylingFnParams) for details

The `style` property can also be specified for [`columnTypes`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#columnTypes)

```ts
import { Component } from '@angular/core';

import { DataSource, InfiniteTable } from '@infinite-table/infinite-angular';
import type { InfiniteTablePropColumns } from '@infinite-table/infinite-angular';

type Developer = {
  id: number;
  firstName: string;
  lastName: string;
  country: string;
  city: string;
  currency: string;
  preferredLanguage: string;
  stack: string;
  canDesign: 'yes' | 'no';
  hobby: string;
  salary: number;
  age: number;
};

const dataSource = () => {
  return fetch(process.env.NEXT_PUBLIC_BASE_URL + '/developers1k')
    .then((r) => r.json())
    .then((data: Developer[]) => data);
};

const columns: InfiniteTablePropColumns<Developer> = {
  id: {
    field: 'id',
    style: {
      background: 'gray',
      color: 'white',
    },
  },
  firstName: { field: 'firstName' },
  preferredLanguage: { field: 'preferredLanguage' },
  salary: {
    field: 'salary',
    type: 'number',
    style: ({ value }) => {
      return {
        color: value && value > 100_000 ? 'red' : 'currentColor',
      };
    },
  },
  stack: { field: 'stack' },
  country: { field: 'country' },
  age: { field: 'age', type: 'number' },

  currency: { field: 'currency', type: 'number' },
};

@Component({
  selector: 'demo-root',
  imports: [DataSource, InfiniteTable],
  template: `
    <infinite-data-source primaryKey="id" [data]="dataSource">
      <infinite-table
        debugId="columns-style-example"
        [columns]="columns"
        [columnDefaultWidth]="200"
      />
    </infinite-data-source>
  `,
})
export default class App {
  protected readonly dataSource = dataSource;
  protected readonly columns = columns;
}
```

### columns.type (`string | string[]`)

> Specifies the column type - a column type is a set of properties that describes the column. Column types allow to easily apply the same properties to multiple columns.

Specifying `type: "number"` for numeric columns will ensure correct number sorting function is used (when sorting is done client-side). This happens because [`sortTypes`](https://infinite-table.com/angular/docs/reference/datasource-props/index.md#sortTypes) has a definition for the `number` sort type.

For date columns (where the values in the columns are actual date objects) specify `type: "date"`. [Read more about date columns here](https://infinite-table.com/angular/docs/learn/working-with-data/handling-dates.md#using-date-strings)

See [`columnTypes`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#columnTypes) for more details on using column types.

By default, all columns have the `default` column type applied. So, if you define the `default` column type, but don't specify any [type](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#columns.type) for a column, the default column type properties will be applied to that column.

When you want both the default type and another type to be applied, you can do so by specifying `type: ["default", "second-type"]`.

When you dont want the default type to be applied, use `type: null`.

If a column is filterable and does not explicitly specify a [filterType](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#columns.filterType), the `type` will also be used as the filter type.

If a column is sortable and does not explicitly specify a [sortType](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#columns.sortType), the `type` will also be used as the sort type.

See the example below - `id` and `age` columns are `type='number'`.

```ts
import { Component } from '@angular/core';

import { DataSource, InfiniteTable } from '@infinite-table/infinite-angular';
import type { InfiniteTablePropColumns } from '@infinite-table/infinite-angular';

import { data } from './data';
import type { Person } from './data';

const columns: InfiniteTablePropColumns<Person> = {
  identifier: {
    field: 'Id',
    type: 'number',
    defaultSortable: true,
    defaultWidth: 80,
  },
  firstName: {
    field: 'FirstName',
  },
  age: { field: 'Age', type: 'number' },
};

@Component({
  selector: 'demo-root',
  imports: [DataSource, InfiniteTable],
  template: `
    <infinite-data-source [data]="data" primaryKey="Id">
      <infinite-table debugId="columns-example" [columns]="columns" />
    </infinite-data-source>
  `,
})
export default class App {
  protected readonly data = data;
  protected readonly columns = columns;
}
```

### columns.valueFormatter (`({ data?, isGroupRow, rowInfo, field?, rowSelected, rowActive, isGroupRow }) => Renderable`)

> Customizes the value that will be rendered

The `valueFormatter` prop is the next function called after the [`columns.valueGetter`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#columns.valueGetter) during the [rendering pipeline](https://infinite-table.com/angular/docs/learn/columns/column-rendering.md#rendering-pipeline). Unlike [`columns.valueGetter`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#columns.valueGetter), [`columns.valueFormatter`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#columns.valueFormatter) can return any renderable value, like `JSX.Element`s.

Unlike `valueGetter`, it is being called with an object that has both the `data` item (might be null or partial for group rows) and the `rowInfo` object, and some extra flags regarding the row state (selection, active, etc). Use the TS `isGroupRow` flag as discriminator to decide if `data` is available.

If you want to further customize what's being rendered, see related [`columns.valueGetter`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#columns.valueGetter), [`columns.renderValue`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#columns.renderValue), [`columns.render`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#columns.render), [`columns.renderGroupValue`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#columns.renderGroupValue), [`columns.renderLeafValue`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#columns.renderLeafValue) and [`columns.renderGroupIcon`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#columns.renderGroupIcon).

**Example: Column with custom valueFormatter**

```ts
import { Component, TemplateRef, viewChild } from '@angular/core';

import {
  DataSource,
  InfiniteTable,
  renderTemplate,
} from '@infinite-table/infinite-angular';
import type { InfiniteTablePropColumns } from '@infinite-table/infinite-angular';

type Developer = {
  id: number;
  firstName: string;
  lastName: string;
  country: string;
  city: string;
  currency: string;
  preferredLanguage: string;
  stack: string;
  canDesign: 'yes' | 'no';
  hobby: string;
  salary: number;
  age: number;
};

const dataSource = () => {
  return fetch(process.env.NEXT_PUBLIC_BASE_URL + '/developers1k')
    .then((r) => r.json())
    .then((data: Developer[]) => data);
};

@Component({
  selector: 'demo-root',
  imports: [DataSource, InfiniteTable],
  template: `
    <infinite-data-source primaryKey="id" [data]="dataSource">
      <infinite-table
        debugId="column-valueFormatter-example"
        [columns]="columns"
        [columnDefaultWidth]="200"
      />
    </infinite-data-source>

    
    <ng-template
      #fullName
      let-data="data"
      let-isGroupRow="isGroupRow"
      let-value="value"
    >
      @if (isGroupRow) {
        <b>{{ value }}</b>
      } @else {
        <b>
          <pre>{{ data.firstName }}, {{ data.lastName }}</pre>
        </b>
      }
    </ng-template>
  `,
})
export default class App {
  protected readonly dataSource = dataSource;

  private readonly fullNameTemplate =
    viewChild.required<TemplateRef<unknown>>('fullName');

  protected readonly columns: InfiniteTablePropColumns<Developer> = {
    id: { field: 'id', defaultWidth: 80 },
    name: {
      header: 'Full Name',
      valueFormatter: ({ data, isGroupRow, value }) => {
        return renderTemplate(this.fullNameTemplate(), {
          data,
          isGroupRow,
          value,
        });
      },
    },

    preferredLanguage: { field: 'preferredLanguage' },
    stack: { field: 'stack' },
  };
}
```

### columns.valueGetter (`({ data, field? }) => string | number | boolean | null | undefined`)

> Customizes the value that will be rendered

The `valueGetter` prop is a function that takes a single argument - an object with `data` and `field` properties. It should return a plain JavaScript value (so not a `ReactNode` or `JSX.Element`)

Note that the `data` property is of type `DATA_TYPE | Partial<DATA_TYPE> | null` and not simply `DATA_TYPE`, because there are cases when you can have grouping (so for group rows with aggregations `data` will be `Partial<DATA_TYPE>`) or when there are lazily loaded rows or group rows with no aggregations - for which `data` is still `null`.

If you want to further customize what's being rendered, see related [`columns.valueFormatter`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#columns.valueFormatter), [`columns.renderValue`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#columns.renderValue), [`columns.render`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#columns.render), [`columns.renderGroupValue`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#columns.renderGroupValue), [`columns.renderLeafValue`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#columns.renderLeafValue) and [`columns.renderGroupIcon`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#columns.renderGroupIcon).

**Example: Column with custom valueGetter**

```ts
import { Component } from '@angular/core';

import { DataSource, InfiniteTable } from '@infinite-table/infinite-angular';
import type { InfiniteTablePropColumns } from '@infinite-table/infinite-angular';

type Developer = {
  id: number;
  firstName: string;
  lastName: string;
  country: string;
  city: string;
  currency: string;
  preferredLanguage: string;
  stack: string;
  canDesign: 'yes' | 'no';
  hobby: string;
  salary: number;
  age: number;
};

const dataSource = () => {
  return fetch(process.env.NEXT_PUBLIC_BASE_URL + '/developers1k')
    .then((r) => r.json())
    .then((data: Developer[]) => data);
};

const columns: InfiniteTablePropColumns<Developer> = {
  id: { field: 'id', defaultWidth: 80 },
  name: {
    header: 'Full Name',
    valueGetter: ({ data }) => `${data.firstName} ${data.lastName}`,
  },

  preferredLanguage: { field: 'preferredLanguage' },
  stack: { field: 'stack' },
};

@Component({
  selector: 'demo-root',
  imports: [DataSource, InfiniteTable],
  template: `
    <infinite-data-source primaryKey="id" [data]="dataSource">
      <infinite-table
        debugId="column-valueGetter-example"
        [columns]="columns"
        [columnDefaultWidth]="200"
      />
    </infinite-data-source>
  `,
})
export default class App {
  protected readonly dataSource = dataSource;
  protected readonly columns = columns;
}
```

### columnSizing (`Record<string,{width,flex,...}>`)

> Defines the sizing of columns in the grid.

This is a controlled property. For the uncontrolled version, see [`defaultColumnSizing`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#defaultColumnSizing).

It is an object that maps column ids to column sizing options. The values in the objects can contain the following properties:

- [flex](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#columnSizing.flex) - use this for flexible columns. Behaves like the `flex` CSS property.
- [width](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#columnSizing.width) - use this for fixed sized columns
- [minWidth](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#columnSizing.minWidth) - specifies the minimum width of the column. Useful for flexible columns or for restricting users resizing both fixed and flexible columns.
- [maxWidth](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#columnSizing.maxWidth) - specifies the maximum width of the column. Useful for flexible columns or for restricting users resizing both fixed and flexible columns.

**Example: Controlled column sizing**

```ts
import { Component, signal } from '@angular/core';
import { JsonPipe } from '@angular/common';

import { DataSource, InfiniteTable } from '@infinite-table/infinite-angular';
import type {
  InfiniteTablePropColumnSizing,
  InfiniteTablePropColumns,
} from '@infinite-table/infinite-angular';

type Employee = {
  id: number;
  companyName: string;
  companySize: string;
  firstName: string;
  lastName: string;
  country: string;
  countryCode: string;
  city: string;
  streetName: string;
  streetNo: string;
  department: string;
  team: string;
  salary: number;
  age: number;
  email: string;
};

const columns: InfiniteTablePropColumns<Employee> = {
  firstName: {
    field: 'firstName',
    header: 'First Name',
  },
  country: {
    field: 'country',
    header: 'Country',
  },

  city: {
    field: 'city',
    header: 'City',
  },

  salary: {
    field: 'salary',
    type: 'number',
    header: 'Salary',
  },
};

const dataSource = () => {
  return fetch(process.env.NEXT_PUBLIC_BASE_URL + '/employees100')
    .then((r) => r.json())
    .then((data: Employee[]) => data);
};

@Component({
  selector: 'demo-root',
  imports: [DataSource, InfiniteTable, JsonPipe],
  template: `
    <p style="color: var(--infinite-cell-color)">
      Current column sizing:
      <code>
        <pre>{{ columnSizing() | json }}</pre>
      </code>
      Viewport reserved width: {{ viewportReservedWidth() }} -
      <button (click)="viewportReservedWidth.set(0)">click to reset to 0</button>
    </p>
    <infinite-data-source [data]="dataSource" primaryKey="id">
      <infinite-table
        debugId="columnSizing-example"
        [columns]="columns"
        [columnDefaultWidth]="50"
        [(columnSizing)]="columnSizing"
        [(viewportReservedWidth)]="viewportReservedWidth"
      />
    </infinite-data-source>
  `,
})
export default class App {
  protected readonly dataSource = dataSource;
  protected readonly columns = columns;

  
  protected readonly columnSizing = signal<InfiniteTablePropColumnSizing>({
    country: { width: 100 },
    city: { flex: 1, minWidth: 100 },
    salary: { flex: 2, maxWidth: 500 },
  });

  protected readonly viewportReservedWidth = signal(0);
}
```

For auto-sizing columns, see [`autoSizeColumnsKey`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#autoSizeColumnsKey).

### columnSizing.flex (`number`)

> Specifies the flex value for the column.

See [using flexible column sizing section](https://infinite-table.com/angular/docs/learn/columns/fixed-and-flexible-size.md#using-flexible-column-sizing) for more details.

A column can either be flexible or fixed-width. For fixed columns, use [`columnSizing.width`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#columnSizing.width) if you're using [`[(columnSizing)]`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#columnSizing) or [column.defaultWidth](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#columns.defaultWidth) for default-uncontrolled sizing.

**Example: Controlled column sizing with flex columns**

```ts
import { Component, signal } from '@angular/core';
import { JsonPipe } from '@angular/common';

import { DataSource, InfiniteTable } from '@infinite-table/infinite-angular';
import type {
  InfiniteTablePropColumnSizing,
  InfiniteTablePropColumns,
} from '@infinite-table/infinite-angular';

type Employee = {
  id: number;
  companyName: string;
  companySize: string;
  firstName: string;
  lastName: string;
  country: string;
  countryCode: string;
  city: string;
  streetName: string;
  streetNo: string;
  department: string;
  team: string;
  salary: number;
  age: number;
  email: string;
};

const columns: InfiniteTablePropColumns<Employee> = {
  firstName: {
    field: 'firstName',
    header: 'First Name',
  },
  country: {
    field: 'country',
    header: 'Country',
  },

  city: {
    field: 'city',
    header: 'City',
  },

  salary: {
    field: 'salary',
    type: 'number',
    header: 'Salary',
  },
};

const dataSource = () => {
  return fetch(process.env.NEXT_PUBLIC_BASE_URL + '/employees100')
    .then((r) => r.json())
    .then((data: Employee[]) => data);
};

@Component({
  selector: 'demo-root',
  imports: [DataSource, InfiniteTable, JsonPipe],
  template: `
    <p style="color: var(--infinite-cell-color)">
      Current column sizing:
      <code>
        <pre>{{ columnSizing() | json }}</pre>
      </code>
      Viewport reserved width: {{ viewportReservedWidth() }} -
      <button (click)="viewportReservedWidth.set(0)">click to reset to 0</button>
    </p>
    <infinite-data-source [data]="dataSource" primaryKey="id">
      <infinite-table
        debugId="columnSizing-example"
        [columns]="columns"
        [columnDefaultWidth]="50"
        [(columnSizing)]="columnSizing"
        [(viewportReservedWidth)]="viewportReservedWidth"
      />
    </infinite-data-source>
  `,
})
export default class App {
  protected readonly dataSource = dataSource;
  protected readonly columns = columns;

  
  protected readonly columnSizing = signal<InfiniteTablePropColumnSizing>({
    country: { width: 100 },
    city: { flex: 1, minWidth: 100 },
    salary: { flex: 2, maxWidth: 500 },
  });

  protected readonly viewportReservedWidth = signal(0);
}
```

### columnSizing.minWidth (`number`)

> Specifies the minimum width for a column. Especially useful for flexible columns.

See [Using flexible column sizing](https://infinite-table.com/angular/docs/learn/columns/fixed-and-flexible-size.md#using-flexible-column-sizing) for more details on the flex algorithm.

This can also be specified for all columns by specifying [`columnMinWidth`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#columnMinWidth).

**Example: Controlled column sizing with minWidth for column**

```ts
import { Component, signal } from '@angular/core';
import { JsonPipe } from '@angular/common';

import { DataSource, InfiniteTable } from '@infinite-table/infinite-angular';
import type {
  InfiniteTablePropColumnSizing,
  InfiniteTablePropColumns,
} from '@infinite-table/infinite-angular';

type Employee = {
  id: number;
  companyName: string;
  companySize: string;
  firstName: string;
  lastName: string;
  country: string;
  countryCode: string;
  city: string;
  streetName: string;
  streetNo: string;
  department: string;
  team: string;
  salary: number;
  age: number;
  email: string;
};

const columns: InfiniteTablePropColumns<Employee> = {
  firstName: {
    field: 'firstName',
    header: 'First Name',
  },
  country: {
    field: 'country',
    header: 'Country',
  },

  city: {
    field: 'city',
    header: 'City',
  },

  salary: {
    field: 'salary',
    type: 'number',
    header: 'Salary',
  },
};

const dataSource = () => {
  return fetch(process.env.NEXT_PUBLIC_BASE_URL + '/employees100')
    .then((r) => r.json())
    .then((data: Employee[]) => data);
};

@Component({
  selector: 'demo-root',
  imports: [DataSource, InfiniteTable, JsonPipe],
  template: `
    <p style="color: var(--infinite-cell-color)">
      Current column sizing:
      <code>
        <pre>{{ columnSizing() | json }}</pre>
      </code>
      Viewport reserved width: {{ viewportReservedWidth() }} -
      <button (click)="viewportReservedWidth.set(0)">click to reset to 0</button>
    </p>
    <infinite-data-source [data]="dataSource" primaryKey="id">
      <infinite-table
        debugId="columnSizing-example"
        [columns]="columns"
        [columnDefaultWidth]="50"
        [(columnSizing)]="columnSizing"
        [(viewportReservedWidth)]="viewportReservedWidth"
      />
    </infinite-data-source>
  `,
})
export default class App {
  protected readonly dataSource = dataSource;
  protected readonly columns = columns;

  
  protected readonly columnSizing = signal<InfiniteTablePropColumnSizing>({
    country: { width: 100 },
    city: { flex: 1, minWidth: 100 },
    salary: { flex: 2, maxWidth: 500 },
  });

  protected readonly viewportReservedWidth = signal(0);
}
```

### columnSizing.maxWidth (`number`)

> Specifies the maximum width for a column. Especially useful for flexible columns.

See [Using flexible column sizing](https://infinite-table.com/angular/docs/learn/columns/fixed-and-flexible-size.md#using-flexible-column-sizing) for more details on the flex algorithm.

This can also be specified for all columns by specifying [`columnMaxWidth`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#columnMaxWidth).

**Example: Controlled column sizing with maxWidth for column**

```ts
import { Component, signal } from '@angular/core';
import { JsonPipe } from '@angular/common';

import { DataSource, InfiniteTable } from '@infinite-table/infinite-angular';
import type {
  InfiniteTablePropColumnSizing,
  InfiniteTablePropColumns,
} from '@infinite-table/infinite-angular';

type Employee = {
  id: number;
  companyName: string;
  companySize: string;
  firstName: string;
  lastName: string;
  country: string;
  countryCode: string;
  city: string;
  streetName: string;
  streetNo: string;
  department: string;
  team: string;
  salary: number;
  age: number;
  email: string;
};

const columns: InfiniteTablePropColumns<Employee> = {
  firstName: {
    field: 'firstName',
    header: 'First Name',
  },
  country: {
    field: 'country',
    header: 'Country',
  },

  city: {
    field: 'city',
    header: 'City',
  },

  salary: {
    field: 'salary',
    type: 'number',
    header: 'Salary',
  },
};

const dataSource = () => {
  return fetch(process.env.NEXT_PUBLIC_BASE_URL + '/employees100')
    .then((r) => r.json())
    .then((data: Employee[]) => data);
};

@Component({
  selector: 'demo-root',
  imports: [DataSource, InfiniteTable, JsonPipe],
  template: `
    <p style="color: var(--infinite-cell-color)">
      Current column sizing:
      <code>
        <pre>{{ columnSizing() | json }}</pre>
      </code>
      Viewport reserved width: {{ viewportReservedWidth() }} -
      <button (click)="viewportReservedWidth.set(0)">click to reset to 0</button>
    </p>
    <infinite-data-source [data]="dataSource" primaryKey="id">
      <infinite-table
        debugId="columnSizing-example"
        [columns]="columns"
        [columnDefaultWidth]="50"
        [(columnSizing)]="columnSizing"
        [(viewportReservedWidth)]="viewportReservedWidth"
      />
    </infinite-data-source>
  `,
})
export default class App {
  protected readonly dataSource = dataSource;
  protected readonly columns = columns;

  
  protected readonly columnSizing = signal<InfiniteTablePropColumnSizing>({
    country: { width: 100 },
    city: { flex: 1, minWidth: 100 },
    salary: { flex: 2, maxWidth: 500 },
  });

  protected readonly viewportReservedWidth = signal(0);
}
```

### columnSizing.width (`number`)

> Specifies the fixed width for the column.

See [Using flexible column sizing](https://infinite-table.com/angular/docs/learn/columns/fixed-and-flexible-size.md#using-flexible-column-sizing) for more details.

A column can either be flexible or fixed. For flexible columns, use [`columnSizing.flex`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#columnSizing.flex).

**Example: Controlled column sizing with fixed column**

```ts
import { Component, signal } from '@angular/core';
import { JsonPipe } from '@angular/common';

import { DataSource, InfiniteTable } from '@infinite-table/infinite-angular';
import type {
  InfiniteTablePropColumnSizing,
  InfiniteTablePropColumns,
} from '@infinite-table/infinite-angular';

type Employee = {
  id: number;
  companyName: string;
  companySize: string;
  firstName: string;
  lastName: string;
  country: string;
  countryCode: string;
  city: string;
  streetName: string;
  streetNo: string;
  department: string;
  team: string;
  salary: number;
  age: number;
  email: string;
};

const columns: InfiniteTablePropColumns<Employee> = {
  firstName: {
    field: 'firstName',
    header: 'First Name',
  },
  country: {
    field: 'country',
    header: 'Country',
  },

  city: {
    field: 'city',
    header: 'City',
  },

  salary: {
    field: 'salary',
    type: 'number',
    header: 'Salary',
  },
};

const dataSource = () => {
  return fetch(process.env.NEXT_PUBLIC_BASE_URL + '/employees100')
    .then((r) => r.json())
    .then((data: Employee[]) => data);
};

@Component({
  selector: 'demo-root',
  imports: [DataSource, InfiniteTable, JsonPipe],
  template: `
    <p style="color: var(--infinite-cell-color)">
      Current column sizing:
      <code>
        <pre>{{ columnSizing() | json }}</pre>
      </code>
      Viewport reserved width: {{ viewportReservedWidth() }} -
      <button (click)="viewportReservedWidth.set(0)">click to reset to 0</button>
    </p>
    <infinite-data-source [data]="dataSource" primaryKey="id">
      <infinite-table
        debugId="columnSizing-example"
        [columns]="columns"
        [columnDefaultWidth]="50"
        [(columnSizing)]="columnSizing"
        [(viewportReservedWidth)]="viewportReservedWidth"
      />
    </infinite-data-source>
  `,
})
export default class App {
  protected readonly dataSource = dataSource;
  protected readonly columns = columns;

  
  protected readonly columnSizing = signal<InfiniteTablePropColumnSizing>({
    country: { width: 100 },
    city: { flex: 1, minWidth: 100 },
    salary: { flex: 2, maxWidth: 500 },
  });

  protected readonly viewportReservedWidth = signal(0);
}
```

### keyboardShortcuts (`{key,handler,when}[]`)

> An array that specifies the keyboard shortcuts for the DataGrid.

See the [Keyboard Shortcuts](https://infinite-table.com/angular/docs/learn/keyboard-navigation/keyboard-shortcuts.md) page for more details.

Click on a cell and use the keyboard to navigate.

Press `Shift+Enter` to show an alert with the current active cell position.

```ts
import { Component } from '@angular/core';

import { DataSource, InfiniteTable } from '@infinite-table/infinite-angular';
import type {
  DataSourceData,
  InfiniteTablePropColumns,
  InfiniteTablePropKeyboardShorcut,
} from '@infinite-table/infinite-angular';

type Developer = {
  id: number;
  firstName: string;
  lastName: string;
  country: string;
  city: string;
  currency: string;
  preferredLanguage: string;
  stack: string;
  canDesign: 'yes' | 'no';
  hobby: string;
  salary: number;
  age: number;
};

const dataSource: DataSourceData<Developer> = () => {
  return fetch(process.env.NEXT_PUBLIC_BASE_URL + `/developers1k-sql?`)
    .then((r) => r.json())
    .then((data: Developer[]) => data);
};

const columns: InfiniteTablePropColumns<Developer> = {
  preferredLanguage: { field: 'preferredLanguage', header: 'Language' },
  country: { field: 'country', header: 'Country' },
  salary: {
    field: 'salary',
    type: 'number',
  },
  age: { field: 'age' },
  canDesign: { field: 'canDesign' },
  firstName: { field: 'firstName' },
  stack: { field: 'stack' },
  id: { field: 'id' },
  hobby: { field: 'hobby' },
  city: { field: 'city' },
  currency: { field: 'currency' },
};

const keyboardShortcuts: InfiniteTablePropKeyboardShorcut[] = [
  {
    key: 'Shift+Enter',
    when: (context) => !!context.getState().activeCellIndex,
    handler: (context) => {
      const { activeCellIndex } = context.getState();

      const [rowIndex, columnIndex] = activeCellIndex!;
      alert(`Current active cell: row ${rowIndex}, column ${columnIndex}.`);
    },
  },
  {
    key: 'PageUp',
    handler: () => {
      console.log('PageUp key pressed.');
    },
  },
  {
    key: 'PageDown',
    handler: () => {
      console.log('PageDown key pressed.');
    },
  },
];

@Component({
  selector: 'demo-root',
  imports: [DataSource, InfiniteTable],
  template: `
    <infinite-data-source primaryKey="id" [data]="dataSource">
      <infinite-table
        debugId="keyboard-shortcuts-initial-example"
        [columns]="columns"
        [keyboardShortcuts]="keyboardShortcuts"
      />
    </infinite-data-source>
  `,
})
export default class App {
  protected readonly dataSource = dataSource;
  protected readonly columns = columns;
  protected readonly keyboardShortcuts = keyboardShortcuts;
}
```

Infinite Table DataGrid comes with some predefined keyboard shorcuts.
you can import from the `keyboardShortcuts` named export.
```ts
import { keyboardShortcuts } from '@infinite-table/infinite-angular';
```

#### Instant Edit

```ts
import { Component } from '@angular/core';
import {
  DataSource,
  InfiniteTable,
  keyboardShortcuts,
} from '@infinite-table/infinite-angular';

@Component({
  selector: 'app-root',
  imports: [DataSource, InfiniteTable],
  template: `
    <infinite-data-source primaryKey="id" [data]="dataSource">
      <infinite-table
        [columns]="columns"
        [keyboardShortcuts]="keyboardShortcuts"
      />
    </infinite-data-source>
  `,
})
export class App {
  protected readonly dataSource = dataSource;
  protected readonly columns = columns;
  protected readonly keyboardShortcuts = [
    keyboardShortcuts.instantEdit,
  ];
}
```

For now, the only predefined keyboard shorcut is `keyboardShortcuts.instantEdit`. This keyboard shorcut starts cell editing when any key is pressed on the active cell. This is the same behavior found in Excel/Google Sheets.

Click on a cell and then start typing to edit the cell.

```ts
import { Component } from '@angular/core';

import {
  DataSource,
  InfiniteTable,
  keyboardShortcuts,
} from '@infinite-table/infinite-angular';
import type {
  DataSourceData,
  InfiniteTablePropColumns,
} from '@infinite-table/infinite-angular';

type Developer = {
  id: number;
  firstName: string;
  lastName: string;
  country: string;
  city: string;
  currency: string;
  preferredLanguage: string;
  stack: string;
  canDesign: 'yes' | 'no';
  hobby: string;
  salary: number;
  age: number;
};

const dataSource: DataSourceData<Developer> = () => {
  return fetch(process.env.NEXT_PUBLIC_BASE_URL + `/developers1k-sql?`)
    .then((r) => r.json())
    .then((data: Developer[]) => data);
};

const columns: InfiniteTablePropColumns<Developer> = {
  preferredLanguage: { field: 'preferredLanguage', header: 'Language' },
  country: { field: 'country', header: 'Country' },
  salary: {
    field: 'salary',
    type: 'number',
  },
  age: { field: 'age' },
  canDesign: { field: 'canDesign' },
  firstName: { field: 'firstName' },
  stack: { field: 'stack' },
  id: { field: 'id', defaultEditable: false },
  hobby: { field: 'hobby' },
  city: { field: 'city' },
  currency: { field: 'currency' },
};

@Component({
  selector: 'demo-root',
  imports: [DataSource, InfiniteTable],
  template: `
    <infinite-data-source primaryKey="id" [data]="dataSource">
      <infinite-table
        debugId="keyboard-shortcuts-instant-edit-example"
        [columns]="columns"
        [columnDefaultEditable]="true"
        [keyboardShortcuts]="[keyboardShortcuts.instantEdit]"
      />
    </infinite-data-source>
  `,
})
export default class App {
  protected readonly dataSource = dataSource;
  protected readonly columns = columns;
  protected readonly keyboardShortcuts = keyboardShortcuts;
}
```

### columnTypes (`Record<string,InfiniteTableColumnType>`)

> Specifies an object that maps column type ids to column types. Column types are used to apply the same configuration/properties to multiple columns. See related [`columns.type`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#columns.type)

By default, all columns have the `default` column type applied. So, if you define the `default` column type, but don't specify any [type](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#columns.type) for a column, the default column type properties will be applied to that column.

The following properties are currently supported for defining a column type:

- `align` - See [`columns.align`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#columns.align)
- `className` - See [`columns.className`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#columns.className)
- `components` - See [`columns.components`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#columns.components)
- `cssEllipsis` - See [`columns.cssEllipsis`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#columns.cssEllipsis)
- `defaultEditable` - See [`columns.defaultEditable`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#columns.defaultEditable)
- `defaultFlex` - default flex value (uncontrolled) for the column(s) this column type will be applied to. See [`column.defaultFlex`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#column.defaultFlex)
- `defaultWidth` - default width (uncontrolled) for the column(s) this column type will be applied to. See [`column.defaultWidth`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#column.defaultWidth)
- `getValueToEdit` - See [`columns.getValueToEdit`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#columns.getValueToEdit)
- `getValueToPersist` - See [`columns.getValueToPersist`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#columns.getValueToPersist)
- `headerAlign` - See [`columns.headerAlign`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#columns.headerAlign)
- `headerCssEllipsis` - See [`columns.headerCssEllipsis`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#columns.headerCssEllipsis)
- `headerStyle` - See [`columns.headerStyle`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#columns.headerStyle)
- `header` - See [`columns.header`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#columns.header)
- `maxWidth` - minimum width for the column(s) this column type will be applied to. See [`column.maxWidth`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#column.maxWidth)
- `minWidth` - minimum width for the column(s) this column type will be applied to. See [`column.minWidth`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#column.minWidth)
- `renderMenuIcon` - See [`columns.renderMenuIcon`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#columns.renderMenuIcon)
- `renderSortIcon` - See [`columns.renderSortIcon`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#columns.renderSortIcon)
- `renderValue` - See [`columns.renderValue`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#columns.renderValue)
- `render` - render function for the column(s) this column type will be applied to. See [`column.render`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#column.render)
- `shouldAcceptEdit` - See [`columns.shouldAcceptEdit`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#columns.shouldAcceptEdit)
- `sortable` - See [`columns.sortable`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#columns.sortable)
- `style` - See [`columns.style`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#columns.style)
- `valueFormatter` - See [`columns.valueFormatter`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#columns.valueFormatter)
- `valueGetter` - See [`columns.valueGetter`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#columns.valueGetter)
- `verticalAlign` - See [`columns.verticalAlign`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#columns.verticalAlign)

When any of the properties defined in a column type are also defined in a column (or in column sizing/pinning,etc), the later take precedence so the properties in column type are not applied.

The only exception to this rule is the [components](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#columns.components) property, which is merged from column types into the column.

This is a basic example integrating with the [MUI X Date Picker](https://mui.com/x/react-date-pickers/date-picker/) - click any cell in the **Birth Date** or **Date Hired** columns to show the date picker.

This example uses the [column types](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#columnTypes) to give each date column the same editor and styling.

**Example: Using MUI X Date Picker with custom 'date' type columns**

```ts
import { Component, ElementRef, TemplateRef, viewChild } from '@angular/core';
import type { AfterViewInit } from '@angular/core';

import {
  DataSource,
  InfiniteTable,
  injectColumnEditor,
} from '@infinite-table/infinite-angular';
import type {
  InfiniteTablePropColumnTypes,
  InfiniteTablePropColumns,
} from '@infinite-table/infinite-angular';

type Developer = {
  birthDate: Date;
  dateHired: Date;
  id: number;
  firstName: string;
  country: string;
  city: string;
  currency: string;
  email: string;
  preferredLanguage: string;
  hobby: string;
  salary: number;
};

const pad = (n: number) => String(n).padStart(2, '0');

// YYYY-MM-DD, the format of a native date input
function formatDate(date: Date | null | undefined) {
  if (!date) {
    return '';
  }
  return `${date.getFullYear()}-${pad(date.getMonth() + 1)}-${pad(
    date.getDate(),
  )}`;
}

function parseDate(value: string) {
  if (!value) {
    return null;
  }
  const [year, month, day] = value.split('-').map(Number);
  return new Date(year, month - 1, day);
}

// a native date input - picking a date confirms the edit,
// Escape or leaving the editor cancels it
@Component({
  selector: 'date-editor',
  template: `
    <input
      #input
      type="date"
      style="width: 100%; height: 100%; box-sizing: border-box; background: white; color: black; padding: 3px; border: none"
      [value]="initialValue"
      (change)="onChange()"
      (keydown)="onKeydown($event)"
      (blur)="cancel()"
    />
  `,
})
class DateEditor implements AfterViewInit {
  protected readonly editor = injectColumnEditor();
  protected readonly initialValue = formatDate(this.editor.initialValue);

  private readonly input =
    viewChild.required<ElementRef<HTMLInputElement>>('input');

  // true once the user types in the input: then Enter confirms the date
  private typing = false;
  private done = false;

  ngAfterViewInit() {
    const input = this.input().nativeElement;
    input.focus();
    try {
      // open the calendar, as the editor opens
      input.showPicker();
    } catch {
      // no picker (no user activation, or not supported)
    }
  }

  protected onChange() {
    if (!this.typing) {
      // a date picked from the calendar
      this.confirm();
    }
  }

  protected onKeydown(event: KeyboardEvent) {
    const { key } = event;
    if (key === 'Enter') {
      this.confirm();
    } else if (key === 'Escape') {
      this.cancel();
    } else {
      this.typing = true;
    }
    // the keys are for the date input, not for the grid
    event.stopPropagation();
  }

  private confirm() {
    const date = parseDate(this.input().nativeElement.value);
    if (!date) {
      this.cancel();
      return;
    }
    if (!this.done) {
      this.done = true;
      this.editor.confirmEdit(date);
    }
  }

  protected cancel() {
    if (!this.done) {
      this.done = true;
      this.editor.cancelEdit();
    }
  }
}

const columns: InfiniteTablePropColumns<Developer> = {
  firstName: { field: 'firstName', header: 'First Name' },
  birthDate: {
    field: 'birthDate',
    header: 'Birth Date',
    // we need to specify the type of the column as "date"
    type: 'date',
  },
  dateHired: {
    field: 'dateHired',
    header: 'Date Hired',
    // we need to specify the type of the column as "date"
    type: 'date',
  },
  salary: {
    field: 'salary',
    header: 'Salary',
    type: 'number',
  },
  country: { field: 'country', header: 'Country' },
  preferredLanguage: { field: 'preferredLanguage' },
  id: { field: 'id' },
  hobby: { field: 'hobby' },
  city: { field: 'city' },
  currency: { field: 'currency' },
};

@Component({
  selector: 'demo-root',
  imports: [DataSource, InfiniteTable],
  template: `
    <infinite-data-source primaryKey="id" [data]="dataSource">
      <infinite-table
        debugId="column-types-date-editor-example"
        [columnTypes]="columnTypes"
        [columns]="columns"
        [columnDefaultWidth]="120"
      />
    </infinite-data-source>

    <ng-template #dateValue let-value="value">
      <b>{{ formatDate(value) }}</b>
    </ng-template>
  `,
})
export default class App {
  protected readonly dataSource = dataSource;
  protected readonly columns = columns;
  protected readonly formatDate = formatDate;

  private readonly dateValueTemplate =
    viewChild.required<TemplateRef<unknown>>('dateValue');

  protected readonly columnTypes: InfiniteTablePropColumnTypes<Developer> = {
    date: {
      defaultEditable: true,
      components: {
        Editor: DateEditor,
      },
      defaultWidth: 200,
      style: ({ inEdit }) => {
        return inEdit ? { padding: 0 } : {};
      },
      renderValue: () => this.dateValueTemplate(),
    },
  };
}

const dataSource: Developer[] = [
  {
    id: 0,
    firstName: 'Nya',
    country: 'India',
    city: 'Unnao',
    birthDate: new Date(1997, 0, 1),
    dateHired: new Date(2023, 0, 1),
    currency: 'JPY',
    preferredLanguage: 'TypeScript',
    salary: 60000,
    hobby: 'sports',
    email: 'Nya44@gmail.com',
  },
  {
    id: 1,
    firstName: 'Axel',
    country: 'Mexico',
    city: 'Cuitlahuac',
    birthDate: new Date(1993, 3, 10),
    dateHired: new Date(2022, 5, 10),
    currency: 'USD',
    preferredLanguage: 'TypeScript',
    salary: 100000,
    hobby: 'sports',
    email: 'Axel93@hotmail.com',
  },
  {
    id: 2,
    firstName: 'Gonzalo',
    country: 'United Arab Emirates',
    city: 'Fujairah',
    birthDate: new Date(1997, 10, 30),
    dateHired: new Date(2021, 8, 29),
    currency: 'JPY',
    preferredLanguage: 'Go',
    salary: 120000,
    hobby: 'photography',
    email: 'Gonzalo_McGlynn34@gmail.com',
  },
  {
    id: 3,
    firstName: 'Sherwood',
    country: 'Mexico',
    city: 'Tlacolula de Matamoros',
    birthDate: new Date(1990, 5, 20),
    dateHired: new Date(2021, 8, 20),
    currency: 'CHF',
    preferredLanguage: 'Rust',
    salary: 99000,
    hobby: 'cooking',
    email: 'Sherwood_McLaughlin65@hotmail.com',
  },
  {
    id: 4,
    firstName: 'Alexandre',
    country: 'France',
    city: 'Persan',
    birthDate: new Date(1990, 3, 20),
    dateHired: new Date(2023, 11, 12),
    currency: 'EUR',
    preferredLanguage: 'Go',
    salary: 97000,
    hobby: 'reading',
    email: 'Alexandre_Harber@hotmail.com',
  },
  {
    id: 5,
    firstName: 'Mariane',
    country: 'United States',
    city: 'Hays',
    birthDate: new Date(2002, 3, 20),
    dateHired: new Date(2022, 2, 22),
    currency: 'EUR',
    preferredLanguage: 'TypeScript',

    salary: 58000,
    hobby: 'cooking',
    email: 'Mariane0@hotmail.com',
  },
  {
    id: 6,
    firstName: 'Rosalind',
    country: 'Mexico',
    city: 'Nuevo Casas Grandes',
    birthDate: new Date(1992, 11, 12),
    dateHired: new Date(2022, 1, 12),
    currency: 'AUD',
    preferredLanguage: 'JavaScript',
    salary: 198000,
    hobby: 'dancing',
    email: 'Rosalind69@gmail.com',
  },
  {
    id: 7,
    firstName: 'Lolita',
    country: 'Sweden',
    city: 'Delsbo',
    birthDate: new Date(1990, 9, 5),
    dateHired: new Date(2022, 1, 5),
    currency: 'JPY',
    preferredLanguage: 'TypeScript',
    salary: 200000,
    hobby: 'cooking',
    email: 'Lolita.Hayes@hotmail.com',
  },
  {
    id: 8,
    firstName: 'Tre',
    country: 'Germany',
    city: 'Bad Camberg',
    birthDate: new Date(1990, 9, 15),
    dateHired: new Date(2022, 10, 1),
    currency: 'GBP',
    preferredLanguage: 'TypeScript',
    salary: 200000,
    hobby: 'sports',
    email: 'Tre28@gmail.com',
  },
  {
    id: 9,
    firstName: 'Lurline',
    country: 'Canada',
    city: 'Raymore',
    birthDate: new Date(1990, 4, 18),
    dateHired: new Date(2023, 3, 18),
    currency: 'EUR',
    preferredLanguage: 'Rust',
    salary: 58000,
    hobby: 'sports',
    email: 'Lurline_Deckow@gmail.com',
  },
];
```

### columnTypes.components

> See related [`columns.components`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#columns.components).

### columnTypes.defaultFlex (`number`)

> Specifies a default flex value for the column type. Will be overriden in any column that already specifies a `defaultFlex` property.

See related [`columnTypes.defaultWidth`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#columnTypes.defaultWidth), [`columns.defaultFlex`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#columns.defaultFlex) and [`columns.defaultWidth`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#columns.defaultWidth)

### columnTypes.defaultSortable (`boolean`)

> Specifies whether columns of this type are sortable.

This prop overrides the component-level [`columnDefaultSortable`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#columnDefaultSortable).

This prop is overriden by [`columns.defaultSortable`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#columns.defaultSortable) and [`sortable`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#sortable).

### columnTypes.headerClassName (`string | (args) => string`)

> Controls styling for the column header for columns with this column type. Can be a string or a function returning a string.

See docs at [`columns.headerClassName`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#columns.headerClassName).

### columns.align (`'start' | 'center' | 'end'`)

> Controls the alignment of text in column cells and also the alignment of the column header. To only apply alignment to the column header, use [`columns.headerAlign`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#columns.headerAlign). For vertical alignment, see [`columns.verticalAlign`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#columns.verticalAlign).

For css ellipsis, see [`columns.cssEllipsis`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#columns.cssEllipsis).

**Example: Column align example**

```ts
import { Component, computed, signal } from '@angular/core';

import { DataSource, InfiniteTable } from '@infinite-table/infinite-angular';
import type { InfiniteTablePropColumns } from '@infinite-table/infinite-angular';

type Align = 'start' | 'center' | 'end';

const headerOptions = {
  alwaysReserveSpaceForSortIcon: false,
};

@Component({
  selector: 'demo-root',
  imports: [DataSource, InfiniteTable],
  template: `
    <div style="color: var(--infinite-cell-color); padding: 10px">
      <p>Select the column align</p>
      <select [value]="align()" (change)="onAlignChange($event)">
        <option value="start">Start</option>
        <option value="center">Center</option>
        <option value="end">End</option>
      </select>
    </div>
    <infinite-data-source [data]="dataSource" primaryKey="id">
      <infinite-table
        debugId="column-align-example"
        [columns]="columns()"
        [columnDefaultWidth]="250"
        [headerOptions]="headerOptions"
      />
    </infinite-data-source>
  `,
})
export default class App {
  protected readonly dataSource = dataSource;
  protected readonly headerOptions = headerOptions;

  protected readonly align = signal<Align>('start');

  // new columns when the column align changes
  protected readonly columns = computed<InfiniteTablePropColumns<Developer>>(
    () => ({
      firstName: {
        field: 'firstName',

        align: this.align(),
      },
    }),
  );

  protected onAlignChange(event: Event) {
    this.align.set((event.target as HTMLSelectElement).value as Align);
  }
}

const dataSource = () => {
  return fetch(process.env.NEXT_PUBLIC_BASE_URL + '/developers100')
    .then((r) => r.json())
    .then((data: Developer[]) => data);
};

type Developer = {
  id: number;
  firstName: string;
  lastName: string;
  country: string;
  city: string;
  currency: string;
  email: string;
  preferredLanguage: string;
  stack: string;
  canDesign: 'yes' | 'no';
  hobby: string;
  salary: number;
  age: number;
};
```

### columns.verticalAlign (`'start' | 'center' | 'end'`)

> Controls the vertical alignment of text in column cells. For horizontal alignment, see [`columns.align`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#columns.align).

**Example: Column vertical align example**

```ts
import { Component, computed, signal } from '@angular/core';

import { DataSource, InfiniteTable } from '@infinite-table/infinite-angular';
import type { InfiniteTablePropColumns } from '@infinite-table/infinite-angular';

type Align = 'start' | 'center' | 'end';

const headerOptions = {
  alwaysReserveSpaceForSortIcon: false,
};

@Component({
  selector: 'demo-root',
  imports: [DataSource, InfiniteTable],
  template: `
    <div style="color: var(--infinite-cell-color); padding: 10px">
      <p>Select the vertical align</p>
      <select [value]="verticalAlign()" (change)="onVerticalAlignChange($event)">
        <option value="start">Start</option>
        <option value="center">Center</option>
        <option value="end">End</option>
      </select>
    </div>
    <infinite-data-source [data]="dataSource" primaryKey="id">
      <infinite-table
        debugId="column-vertical-align-example"
        [columns]="columns()"
        [columnDefaultWidth]="250"
        [rowHeight]="80"
        [headerOptions]="headerOptions"
      />
    </infinite-data-source>
  `,
})
export default class App {
  protected readonly dataSource = dataSource;
  protected readonly headerOptions = headerOptions;

  protected readonly verticalAlign = signal<Align>('center');

  // new columns when the vertical align changes
  protected readonly columns = computed<InfiniteTablePropColumns<Developer>>(
    () => ({
      firstName: {
        field: 'firstName',

        verticalAlign: this.verticalAlign(),
      },
    }),
  );

  protected onVerticalAlignChange(event: Event) {
    this.verticalAlign.set((event.target as HTMLSelectElement).value as Align);
  }
}

const dataSource = () => {
  return fetch(process.env.NEXT_PUBLIC_BASE_URL + '/developers100')
    .then((r) => r.json())
    .then((data: Developer[]) => data);
};

type Developer = {
  id: number;
  firstName: string;
  lastName: string;
  country: string;
  city: string;
  currency: string;
  email: string;
  preferredLanguage: string;
  stack: string;
  canDesign: 'yes' | 'no';
  hobby: string;
  salary: number;
  age: number;
};
```

### columns.headerAlign (`'start' | 'center' | 'end'`)

> Controls the alignment of the column header. See related [`columns.align`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#columns.align) and [`columns.headerCssEllipsis`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#columns.headerCssEllipsis).

**Example: Column header align example**

```ts
import { Component, computed, signal } from '@angular/core';

import { DataSource, InfiniteTable } from '@infinite-table/infinite-angular';
import type { InfiniteTablePropColumns } from '@infinite-table/infinite-angular';

type Align = 'start' | 'center' | 'end';

const headerOptions = {
  alwaysReserveSpaceForSortIcon: false,
};

@Component({
  selector: 'demo-root',
  imports: [DataSource, InfiniteTable],
  template: `
    <div style="color: var(--infinite-cell-color); padding: 10px">
      <p>Select the header align</p>
      <select [value]="headerAlign()" (change)="onHeaderAlignChange($event)">
        <option value="start">Start</option>
        <option value="center">Center</option>
        <option value="end">End</option>
      </select>
    </div>
    <infinite-data-source [data]="dataSource" primaryKey="id">
      <infinite-table
        debugId="column-header-align-example"
        [columns]="columns()"
        [columnDefaultWidth]="250"
        [headerOptions]="headerOptions"
      />
    </infinite-data-source>
  `,
})
export default class App {
  protected readonly dataSource = dataSource;
  protected readonly headerOptions = headerOptions;

  protected readonly headerAlign = signal<Align>('start');

  // new columns when the header align changes
  protected readonly columns = computed<InfiniteTablePropColumns<Developer>>(
    () => ({
      firstName: {
        field: 'firstName',

        headerAlign: this.headerAlign(),
      },
    }),
  );

  protected onHeaderAlignChange(event: Event) {
    this.headerAlign.set((event.target as HTMLSelectElement).value as Align);
  }
}

const dataSource = () => {
  return fetch(process.env.NEXT_PUBLIC_BASE_URL + '/developers100')
    .then((r) => r.json())
    .then((data: Developer[]) => data);
};

type Developer = {
  id: number;
  firstName: string;
  lastName: string;
  country: string;
  city: string;
  currency: string;
  email: string;
  preferredLanguage: string;
  stack: string;
  canDesign: 'yes' | 'no';
  hobby: string;
  salary: number;
  age: number;
};
```

### columnTypes.headerStyle (`CSSProperties | (args) => CSSProperties`)

> Controls styling for the column header for columns with this column type. Can be a style object or a function returning a style object.

See docs at [`columns.headerStyle`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#columns.headerStyle).

### columnTypes.defaultWidth (`number`)

> Specifies a default fixed width for the column type. Will be overriden in any column that already specifies a `defaultWidth` property.

See related [`columnTypes.defaultFlex`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#columnTypes.defaultFlex), [`columns.defaultWidth`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#columns.defaultWidth) and [`columns.defaultFlex`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#columns.defaultFlex)

### columnTypes.maxWidth (`number`)

> Specifies a default maximum width for the column type. Will be overriden in any column that already specifies a `maxWidth` property.

See related [`columnTypes.maxWidth`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#columnTypes.maxWidth) and [`columns.maxWidth`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#columns.maxWidth)

### columnTypes.minWidth (`number`)

> Specifies a default minimum width for the column type. Will be overriden in any column that already specifies a `minWidth` property.

See related [`columnTypes.maxWidth`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#columnTypes.maxWidth) and [`columns.minWidth`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#columns.minWidth)

### defaultActiveCellIndex (`[number,number]`)

> Specifies the active cell for keyboard navigation. This is an uncontrolled prop. See the [Keyboard Navigation](https://infinite-table.com/angular/docs/learn/keyboard-navigation/navigating-cells.md) page for more details.

See [`[(activeCellIndex)]`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#activeCellIndex) for the controlled version of this prop and
[`keyboardNavigation`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#keyboardNavigation) for the keyboard navigation behavior.

This example starts with cell `[2,0]` already active.

**Example: Uncontrolled keyboard navigation for cells**

```ts
import { Component } from '@angular/core';

import { InfiniteTable, DataSource } from '@infinite-table/infinite-angular';
import type {
  DataSourceData,
  InfiniteTablePropColumns,
} from '@infinite-table/infinite-angular';

type Developer = {
  id: number;
  firstName: string;
  lastName: string;
  country: string;
  city: string;
  currency: string;
  preferredLanguage: string;
  stack: string;
  canDesign: 'yes' | 'no';
  hobby: string;
  salary: number;
  age: number;
};

const dataSource: DataSourceData<Developer> = () => {
  return fetch(process.env.NEXT_PUBLIC_BASE_URL + `/developers1k-sql?`)
    .then((r) => r.json())
    .then((data: Developer[]) => data);
};

const columns: InfiniteTablePropColumns<Developer> = {
  preferredLanguage: { field: 'preferredLanguage' },
  country: { field: 'country' },
  salary: {
    field: 'salary',
    type: 'number',
  },
  age: { field: 'age' },
  canDesign: { field: 'canDesign' },
  firstName: { field: 'firstName' },
  stack: { field: 'stack' },
  id: { field: 'id' },
  hobby: { field: 'hobby' },
  city: { field: 'city' },
  currency: { field: 'currency' },
};

@Component({
  selector: 'demo-root',
  imports: [DataSource, InfiniteTable],
  template: `
    <infinite-data-source primaryKey="id" [data]="dataSource">
      <infinite-table
        debugId="navigating-cells-uncontrolled-example"
        [defaultActiveCellIndex]="[2, 0]"
        [columns]="columns"
      />
    </infinite-data-source>
  `,
})
export default class App {
  protected readonly dataSource = dataSource;
  protected readonly columns = columns;
}
```

### columnsTypes.sortable (`boolean`)

> Specifies the sorting behavior for columns of this type.

Overrides the global [`sortable`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#sortable) prop, but is overriden by the column's own [sortable](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#columns.sortable) property.

### defaultActiveRowIndex (`number`)

> Specifies the active row for keyboard navigation. This is an uncontrolled prop. See the [Keyboard Navigation](https://infinite-table.com/angular/docs/learn/keyboard-navigation/navigating-rows.md) page for more details.

See [`[(activeRowIndex)]`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#activeRowIndex) for the controlled version of this prop and
[`keyboardNavigation`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#keyboardNavigation) for the keyboard navigation behavior.

This example starts with row at index `2` already active.

**Example: Uncontrolled keyboard navigation for rows**

```ts
import { Component } from '@angular/core';

import { InfiniteTable, DataSource } from '@infinite-table/infinite-angular';
import type {
  DataSourceData,
  InfiniteTablePropColumns,
} from '@infinite-table/infinite-angular';

type Developer = {
  id: number;
  firstName: string;
  lastName: string;
  country: string;
  city: string;
  currency: string;
  preferredLanguage: string;
  stack: string;
  canDesign: 'yes' | 'no';
  hobby: string;
  salary: number;
  age: number;
};

const dataSource: DataSourceData<Developer> = () => {
  return fetch(process.env.NEXT_PUBLIC_BASE_URL + `/developers1k-sql?`)
    .then((r) => r.json())
    .then((data: Developer[]) => data);
};

const columns: InfiniteTablePropColumns<Developer> = {
  preferredLanguage: { field: 'preferredLanguage' },
  country: { field: 'country' },
  salary: {
    field: 'salary',
    type: 'number',
  },
  age: { field: 'age' },
  canDesign: { field: 'canDesign' },
  firstName: { field: 'firstName' },
  stack: { field: 'stack' },
  id: { field: 'id' },
  hobby: { field: 'hobby' },
  city: { field: 'city' },
  currency: { field: 'currency' },
};

const domProps = { style: { height: '90vh' } };

@Component({
  selector: 'demo-root',
  imports: [DataSource, InfiniteTable],
  template: `
    <infinite-data-source primaryKey="id" [data]="dataSource">
      <infinite-table
        debugId="navigating-rows-uncontrolled-example"
        [domProps]="domProps"
        [columns]="columns"
        keyboardNavigation="row"
        [defaultActiveRowIndex]="2"
      />
    </infinite-data-source>
  `,
})
export default class App {
  protected readonly dataSource = dataSource;
  protected readonly domProps = domProps;
  protected readonly columns = columns;
}
```

### defaultColumnOrder (`string[]|true`)

> Defines the order in which columns are displayed in the component.

For controlled usage, see [`[(columnOrder)]`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#columnOrder).

When using this uncontrolled prop, you can also listen to [`(columnOrderChange)`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#onColumnOrderChange) to be notified of column order changes

The `defaultColumnOrder` array can contain identifiers that are not yet defined in the [`columns`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#columns) Map or can contain duplicate ids. This is a feature, not a bug. We want to allow you to use the `defaultColumnOrder` in a flexible way so it can define the order of current and future columns.

Displaying the same column twice is a perfectly valid use case.

See [Column Order](https://infinite-table.com/angular/docs/learn/columns/column-order.md) for more details on ordering columns both programatically and via drag & drop.

**Example: Uncontrolled column order**

```ts
import { Component } from '@angular/core';

import { DataSource, InfiniteTable } from '@infinite-table/infinite-angular';
import type { InfiniteTablePropColumns } from '@infinite-table/infinite-angular';

type Employee = {
  id: number;
  companyName: string;
  companySize: string;
  firstName: string;
  lastName: string;
  country: string;
  countryCode: string;
  city: string;
  streetName: string;
  streetNo: string;
  department: string;
  team: string;
  salary: number;
  age: number;
  email: string;
};

const columns: InfiniteTablePropColumns<Employee> = {
  firstName: {
    field: 'firstName',
    header: 'First Name',
  },
  country: {
    field: 'country',
    header: 'Country',
    columnGroup: 'location',
  },
  city: {
    field: 'city',
    header: 'City',
    columnGroup: 'address',
  },
  salary: {
    field: 'salary',
    type: 'number',
    header: 'Salary',
  },
  department: {
    field: 'department',
    header: 'Department',
  },
  team: {
    field: 'team',
    header: 'Team',
  },
  company: { field: 'companyName', header: 'Company' },

  companySize: {
    field: 'companySize',
    header: 'Company Size',
  },
};

const columnOrder = [
  'firstName',
  'notfound',
  'country',
  'team',
  'company',
  'firstName',
  'not existing',
  'companySize',
  'country',
];

const dataSource = () => {
  return fetch(process.env.NEXT_PUBLIC_BASE_URL + '/employees100')
    .then((r) => r.json())
    .then((data: Employee[]) => data);
};

@Component({
  selector: 'demo-root',
  imports: [DataSource, InfiniteTable],
  template: `
    <infinite-data-source [data]="dataSource" primaryKey="id">
      <infinite-table
        debugId="defaultColumnOrder-example"
        [columns]="columns"
        [defaultColumnOrder]="columnOrder"
        [columnDefaultWidth]="200"
      />
    </infinite-data-source>
  `,
})
export default class App {
  protected readonly dataSource = dataSource;
  protected readonly columns = columns;
  protected readonly columnOrder = columnOrder;
}
```

### defaultColumnSizing (`Record<string,{width,flex,...}>`)

> Defines a default sizing of columns in the grid.

This is an uncontrolled property. For the controlled version and more details, see [`[(columnSizing)]`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#columnSizing).

It is an object that maps column ids to column sizing options. The values in the objects can contain the following properties:

- [flex](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#defaultColumnSizing.flex) - use this for flexible columns. Behaves like the `flex` CSS property.
- [width](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#defaultColumnSizing.width) - use this for fixed sized columns
- [minWidth](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#defaultColumnSizing.minWidth) - specifies the minimum width of the column. Useful for flexible columns or for restricting users resizing both fixed and flexible columns.
- [maxWidth](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#defaultColumnSizing.maxWidth) - specifies the maximum width of the column. Useful for flexible columns or for restricting users resizing both fixed and flexible columns.

**Example: Uncontrolled column sizing**

```ts
import { Component } from '@angular/core';

import { DataSource, InfiniteTable } from '@infinite-table/infinite-angular';
import type {
  InfiniteTableColumn,
  InfiniteTablePropColumnSizing,
} from '@infinite-table/infinite-angular';

type Employee = {
  id: number;
  companyName: string;
  companySize: string;
  firstName: string;
  lastName: string;
  country: string;
  countryCode: string;
  city: string;
  streetName: string;
  streetNo: string;
  department: string;
  team: string;
  salary: number;
  age: number;
  email: string;
};

const columns: Record<string, InfiniteTableColumn<Employee>> = {
  firstName: {
    field: 'firstName',
    header: 'First Name',
  },
  country: {
    field: 'country',
    header: 'Country',
  },
  city: {
    field: 'city',
    header: 'City',
  },
  salary: {
    field: 'salary',
    type: 'number',
    header: 'Salary',
  },
};

const defaultColumnSizing: InfiniteTablePropColumnSizing = {
  country: { width: 100 },
  city: { flex: 1, maxWidth: 300 },
  salary: { flex: 2 },
};

const dataSource = () => {
  return fetch(process.env.NEXT_PUBLIC_BASE_URL + '/employees100')
    .then((r) => r.json())
    .then((data: Employee[]) => data);
};

@Component({
  selector: 'demo-root',
  imports: [DataSource, InfiniteTable],
  template: `
    <infinite-data-source [data]="dataSource" primaryKey="id">
      <infinite-table
        debugId="defaultColumnSizing-example"
        [columns]="columns"
        [columnDefaultWidth]="50"
        [defaultColumnSizing]="defaultColumnSizing"
      />
    </infinite-data-source>
  `,
})
export default class App {
  protected readonly dataSource = dataSource;
  protected readonly columns = columns;
  protected readonly defaultColumnSizing = defaultColumnSizing;
}
```

For auto-sizing columns, see [`autoSizeColumnsKey`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#autoSizeColumnsKey).

### defaultColumnSizing.flex (`number`)

> Specifies the flex value for the column.

See [`columnSizing.flex`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#columnSizing.flex) for details.

### defaultColumnSizing.minWidth (`number`)

> Specifies the minimum width for a column. Especially useful for flexible columns.

See [`columnSizing.minWidth`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#columnSizing.minWidth) for details.

### defaultColumnSizing.maxWidth (`number`)

> Specifies the maximum width for a column. Especially useful for flexible columns.

See [`columnSizing.maxWidth`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#columnSizing.maxWidth) for details.

### defaultColumnSizing.width (`number`)

> Specifies the fixed width for the column.

See [`columnSizing.width`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#columnSizing.width) for details.

### domProps (`React.HTMLProps<HTMLDivElement>`)

> DOM properties to be applied to the component root element.

For applying a className when the component is focused, see [`focusedClassName`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#focusedClassName)

For applying a className when the focus is within the component, see [`focusedWithinClassName`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#focusedWithinClassName)

```ts
import { Component } from '@angular/core';

import { DataSource, InfiniteTable } from '@infinite-table/infinite-angular';
import type { InfiniteTableColumn } from '@infinite-table/infinite-angular';

import { data } from './data';
import type { Person } from './data';

const domProps = {
  style: {
    outline: '3px solid tomato',
    height: '100%',
  },
};

const columns: Record<string, InfiniteTableColumn<Person>> = {
  id: {
    // specifies which field from the data source
    // should be rendered in this column
    field: 'Id',
    type: 'number',
    defaultSortable: true,
    defaultWidth: 80,
  },
  firstName: {
    field: 'FirstName',
  },
  age: { field: 'Age', type: 'number' },
};

@Component({
  selector: 'demo-root',
  imports: [DataSource, InfiniteTable],
  template: `
    <infinite-data-source [data]="data" primaryKey="Id">
      <infinite-table
        debugId="domprops-example"
        [domProps]="domProps"
        [columns]="columns"
        (click)="onClick()"
      />
    </infinite-data-source>
  `,
})
export default class App {
  protected readonly data = data;
  protected readonly columns = columns;
  protected readonly domProps = domProps;

  // <infinite-table> is the root element of the grid:
  // DOM events are bound on it like on any other element
  protected onClick() {
    // open browser devtools to see message
    console.log('TABLE CLICKED');
  }
}
```

### editable (`(param) => boolean | Promise<boolean>`)

> Controls whether columns are editable or not.

This overrides both the global [`columnDefaultEditable`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#columnDefaultEditable) prop and the column's own [defaultEditable](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#columns.defaultEditable) property.

This function prop will be called when an edit is triggered on the column. The function will be called with a single object that contains the following properties:

- `value` - the current value of the cell (the value currently displayed, so after [`columns.valueFormatter`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#columns.valueFormatter) and [`columns.renderValue`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#columns.renderValue) have been applied)
- `rawValue` - the current value of the cell, but before any formatting and custom rendering has been applied. This is either the field value from the current data object, or the result of the column [valueGetter](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#columns.valueGetter) function.
- `data` - the data object (of type `DATA_TYPE`) for the current row
- `rowInfo` - the row info object that underlies the row
- `column` - the current column on which editing is invoked
- `api` - a reference to the [InfiniteTable API](https://infinite-table.com/docs/reference/api/index.md)
- `dataSourceApi` - - a reference to the [DataSource API](https://infinite-table.com/angular/docs/reference/datasource-api/index.md)

The function can return a `boolean` value or a `Promise` that resolves to a `boolean` - this means you can asynchronously decide whether the cell is editable or not.

By default, double-clicking an editable cell will show the cell editor. You can prevent this by returning `{preventEdit: true}` from the [`[onCellDoubleClick]`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#onCellDoubleClick) function prop.

### focusedClassName (`string`)

> CSS class name to be applied to the component root element when it has focus.

For applying a className when the focus is within the component, see [`focusedWithinClassName`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#focusedWithinClassName)

For focus style, see [`focusedStyle`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#focusedStyle).

### focusedWithinClassName (`string`)

> CSS class name to be applied to the component root element when there is focus within (inside) the component.

For applying a className when the component root element is focused, see [`focusedClassName`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#focusedClassName)

### focusedStyle

> Specifies the `style` to be applied to the component root element when it has focus.

**Example: focusedStyle example**

```ts
import { Component } from '@angular/core';

import { DataSource, InfiniteTable } from '@infinite-table/infinite-angular';
import type { InfiniteTableColumn } from '@infinite-table/infinite-angular';

import { data } from './data';
import type { Person } from './data';

const focusedStyle = {
  outline: '3px solid tomato',
};

const columns: Record<string, InfiniteTableColumn<Person>> = {
  id: {
    field: 'Id',
    type: 'number',
    defaultSortable: true,
    defaultWidth: 80,
  },
  firstName: {
    field: 'FirstName',
  },
  age: { field: 'Age', type: 'number' },
};

@Component({
  selector: 'demo-root',
  imports: [DataSource, InfiniteTable],
  template: `
    <button autofocus>Button before - to help with focus navigation</button>
    <infinite-data-source [data]="data" primaryKey="Id">
      <infinite-table
        debugId="focusedStyle-example"
        [focusedStyle]="focusedStyle"
        [columns]="columns"
      />
    </infinite-data-source>
    <button>Button after - to help with focus navigation</button>
  `,
})
export default class App {
  protected readonly data = data;
  protected readonly columns = columns;
  protected readonly focusedStyle = focusedStyle;
}
```

### focusedWithinStyle

> Specifies the `style` to be applied to the component root element when there is focus within (inside) the component.

To listen to focusWithin changes, listen to [`(focusWithin)`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#onFocusWithin) and [`(blurWithin)`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#onBlurWithin).

**Example: focusedWithinStyle example - focus an input inside the table to see it in action**

```ts
import { Component, TemplateRef, viewChild } from '@angular/core';

import { DataSource, InfiniteTable } from '@infinite-table/infinite-angular';
import type { InfiniteTableColumn } from '@infinite-table/infinite-angular';

import { data } from './data';
import type { Person } from './data';

const focusedWithinStyle = {
  outline: '3px solid tomato',
};

@Component({
  selector: 'demo-root',
  imports: [DataSource, InfiniteTable],
  template: `
    <infinite-data-source [data]="data" primaryKey="Id">
      <infinite-table
        debugId="focusedWithinStyle-example"
        [focusedWithinStyle]="focusedWithinStyle"
        [columns]="columns"
      />
    </infinite-data-source>

    <ng-template #inputCell let-value="value">
      <input type="text" [value]="value" />
    </ng-template>
  `,
})
export default class App {
  protected readonly data = data;
  protected readonly focusedWithinStyle = focusedWithinStyle;

  private readonly inputCell =
    viewChild.required<TemplateRef<unknown>>('inputCell');

  protected readonly columns: Record<string, InfiniteTableColumn<Person>> = {
    id: {
      field: 'Id',
      type: 'number',
      defaultSortable: true,
      defaultWidth: 80,
    },
    firstName: {
      field: 'FirstName',
      render: () => this.inputCell(),
    },
    age: { field: 'Age', type: 'number' },
  };
}
```

### getCellContextMenuItems (`({data, column, rowInfo}) => MenuItem[] | null | { items: MenuItem[], columns: [{name}] } | Promise`)

> Customises the context menu items for a cell.

If you want to customize the context menu even when the user clicks outside any cell, but inside the table body, use [`getContextMenuItems`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#getContextMenuItems).

The `getCellContextMenuItems` function can return one of the following:

- `null` - no custom context menu will be displayed, the default context menu will be shown (default event behavior not prevented)
- `[]` - an empty array - no custom context menu will be displayed, but the default context menu is not shown - the default event behavior is prevented
- `Array<MenuItem>` - an array of menu items to be displayed in the context menu - each `MenuItem` should have:
  - a unique `key` property,
  - a `label` property with the value to display in the menu cell - it's called `label` because this is the name of the default column in the context menu
  - an optional `onAction({ key, item, hideMenu: () => void })` callback function to handle the click action on the menu item.
  - an optional `onClick(event)` callback function to handle the click event on the menu item.
  - an optional `hideMenuOnAction: boolean` - if `true`, it will close the context menu when the menu item is clicked

**Example: Using context menus**

```ts
import { Component } from '@angular/core';

import { DataSource, InfiniteTable } from '@infinite-table/infinite-angular';
import type {
  InfiniteTablePropColumns,
  InfiniteTablePropGetCellContextMenuItems,
} from '@infinite-table/infinite-angular';

type Developer = {
  id: number;
  firstName: string;
  lastName: string;
  country: string;
  city: string;
  currency: string;
  preferredLanguage: string;
  stack: string;
  canDesign: 'yes' | 'no';
  hobby: string;
  salary: number;
  age: number;
};

const dataSource = () => {
  return fetch(process.env.NEXT_PUBLIC_BASE_URL + '/developers100')
    .then((r) => r.json())
    .then((data: Developer[]) => data);
};

const columns: InfiniteTablePropColumns<Developer> = {
  stack: {
    field: 'stack',
    header: 'Stack',
  },
  firstName: {
    field: 'firstName',
    header: 'Name',
  },
  age: {
    field: 'age',
    header: 'Age',
  },
  hobby: {
    field: 'hobby',
    header: 'Hobby',
  },
  preferredLanguage: {
    header: 'Language',
    field: 'preferredLanguage',
  },
};

const getCellContextMenuItems: InfiniteTablePropGetCellContextMenuItems<
  Developer
> = ({ data, column }) => {
  return [
    {
      key: 'hello',
      label: `Hello, ${data?.lastName} ${data?.firstName}`,
      onClick: () => {
        alert(`Hello, ${data?.lastName} ${data?.firstName}`);
      },
    },
    {
      key: 'col',
      label: `Current clicked column: ${column.header}`,
    },
    {
      key: 'learn',
      label: `Learn`,
      menu: {
        items: [
          {
            key: 'backend',
            label: 'Backend',
            onClick: () => {
              alert(`Learn Backend, ${data?.lastName} ${data?.firstName}`);
            },
          },
          {
            key: 'frontend',
            label: 'Frontend',
            onClick: () => {
              alert(`Learn Frontend, ${data?.lastName} ${data?.firstName}`);
            },
          },
        ],
      },
    },
  ];
};

@Component({
  selector: 'demo-root',
  imports: [DataSource, InfiniteTable],
  template: `
    <infinite-data-source primaryKey="id" [data]="dataSource">
      <infinite-table
        debugId="cell-basic-context-menu-example"
        [columns]="columns"
        [getCellContextMenuItems]="getCellContextMenuItems"
      />
    </infinite-data-source>
  `,
})
export default class App {
  protected readonly dataSource = dataSource;
  protected readonly columns = columns;
  protected readonly getCellContextMenuItems = getCellContextMenuItems;
}
```

This function can also return a `Promise` that resolves to one of the above types. This is useful for lazy loading the context menu items.

When returning a `Promise`, the context menu will be shown after the promise resolves, and the default browser context menu is not shown.

In addition, if you need to configure the context menu to have other columns rather than the default column (named `label`), you can do so by returning an object with `columns` and `items`:

```tsx
const getCellContextMenuItems = () => {
  return {
    columns: [{ name: 'label' }, { name: 'icon' }],
    items: [
      {
        label: 'Welcome',
        icon: '👋',
        key: 'hi',
      },
      {
        label: 'Convert',
        icon: '🔁',
        key: 'convert',
      },
    ],
  };
};
```

Right-click any cell in the table to see a context menu with multiple columns (`icon`, `label` and `description`).

**Example: Customising columns in the context menu**

```ts
import { Component } from '@angular/core';

import { InfiniteTable, DataSource } from '@infinite-table/infinite-angular';
import type {
  InfiniteTablePropColumns,
  InfiniteTablePropGetCellContextMenuItems,
} from '@infinite-table/infinite-angular';

type Developer = {
  id: number;
  firstName: string;
  lastName: string;
  country: string;
  city: string;
  currency: string;
  preferredLanguage: string;
  stack: string;
  canDesign: 'yes' | 'no';
  hobby: string;
  salary: number;
  age: number;
};

const dataSource = () => {
  return fetch(process.env.NEXT_PUBLIC_BASE_URL + '/developers100')
    .then((r) => r.json())
    .then((data: Developer[]) => data);
};

const columns: InfiniteTablePropColumns<Developer> = {
  stack: {
    field: 'stack',
    header: 'Stack',
  },
  firstName: {
    field: 'firstName',
    header: 'Name',
  },
  age: {
    field: 'age',
    header: 'Age',
  },
  hobby: {
    field: 'hobby',
    header: 'Hobby',
  },
  preferredLanguage: {
    header: 'Language',
    field: 'preferredLanguage',
  },
};

const getCellContextMenuItems: InfiniteTablePropGetCellContextMenuItems<
  Developer
> = ({ data, column }) => {
  const columns = [
    { name: 'icon' },
    { name: 'label' },
    { name: 'description' },
  ];
  return {
    columns,
    items: [
      {
        key: 'hello',
        icon: '👋',
        label: `Hello, ${data?.lastName} ${data?.firstName}`,
        description: `This is a description for ${data?.lastName}`,
      },
      {
        key: 'col',
        icon: '🙌',
        label: `Column: ${column.header}`,
        description: `Current clicked column: ${column.header}`,
      },
      {
        key: 'learn',
        icon: '📚',
        label: `Learn`,
        description: `Learn more about ${data?.preferredLanguage}`,
        menu: {
          columns,
          items: [
            {
              key: 'backend',
              label: 'Backend',
              icon: '👨‍💻',
              description: 'In the Backend',
            },
            {
              key: 'frontend',
              label: 'Frontend',
              icon: '👨‍💻',
              description: 'In the Frontend',
            },
          ],
        },
      },
    ],
  };
};

@Component({
  selector: 'demo-root',
  imports: [DataSource, InfiniteTable],
  template: `
    <infinite-data-source primaryKey="id" [data]="dataSource">
      <infinite-table
        debugId="cells-with-custom-columns-context-menu-example"
        [columns]="columns"
        [columnDefaultEditable]="true"
        [getCellContextMenuItems]="getCellContextMenuItems"
      />
    </infinite-data-source>
  `,
})
export default class App {
  protected readonly dataSource = dataSource;
  protected readonly columns = columns;
  protected readonly getCellContextMenuItems = getCellContextMenuItems;
}
```

### getContextMenuItems (`({event, data?, column?, rowInfo}, {api, dataSourceApi}) => MenuItem[] | null | { items: MenuItem[], columns: [{name}] } | Promise`)

> Customises the context menu items for the whole table.

If you want to customize the context menu only when the user clicks inside a cell, use [`getCellContextMenuItems`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#getCellContextMenuItems), which is probably what you're looking for.

The first argument this function is called with has the same shape as the one for [`getCellContextMenuItems`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#getCellContextMenuItems) but all cell-related properties could also be `undefined`. Also, the `event` is available as a property on this object.

If this function returns null, the default context menu of the browser will be shown (default event behavior not prevented).

**Example: Using context menus for the whole table**

```ts
import { Component } from '@angular/core';

import { DataSource, InfiniteTable } from '@infinite-table/infinite-angular';
import type {
  InfiniteTablePropColumns,
  InfiniteTablePropGetContextMenuItems,
} from '@infinite-table/infinite-angular';

type Developer = {
  id: number;
  firstName: string;
  lastName: string;
  country: string;
  city: string;
  currency: string;
  preferredLanguage: string;
  stack: string;
  canDesign: 'yes' | 'no';
  hobby: string;
  salary: number;
  age: number;
};

const dataSource = () => {
  return fetch(process.env.NEXT_PUBLIC_BASE_URL + '/developers100')
    .then((r) => r.json())
    .then((data: Developer[]) => data);
};

const columns: InfiniteTablePropColumns<Developer> = {
  firstName: {
    field: 'firstName',
    header: 'Name',
    defaultWidth: 120,
  },
  age: {
    field: 'age',
    header: 'Age',
    defaultWidth: 100,
  },
  preferredLanguage: {
    header: 'Language',
    defaultWidth: 120,
    field: 'preferredLanguage',
  },
};

const getContextMenuItems: InfiniteTablePropGetContextMenuItems<Developer> = ({
  data,
  column,
}) => {
  if (!data)
    return [
      {
        key: 'add',
        label: 'Add Item',
        onClick: () => {
          alert('Add Item');
        },
      },
    ];

  return [
    {
      key: 'hello',
      label: `Hello, ${data?.lastName} ${data?.firstName}`,
      onClick: () => {
        alert(`Hello, ${data?.lastName} ${data?.firstName}`);
      },
    },
    {
      key: 'col',
      label: `Current clicked column: ${column?.header}`,
    },
    {
      key: 'learn',
      label: `Learn`,
      menu: {
        items: [
          {
            key: 'backend',
            label: 'Backend',
            onClick: () => {
              alert(`Learn Backend, ${data?.lastName} ${data?.firstName}`);
            },
          },
          {
            key: 'frontend',
            label: 'Frontend',
            onClick: () => {
              alert(`Learn Frontend, ${data?.lastName} ${data?.firstName}`);
            },
          },
        ],
      },
    },
  ];
};

@Component({
  selector: 'demo-root',
  imports: [DataSource, InfiniteTable],
  template: `
    <infinite-data-source primaryKey="id" [data]="dataSource">
      <infinite-table
        debugId="table-basic-context-menu-example"
        [columns]="columns"
        [getContextMenuItems]="getContextMenuItems"
      />
    </infinite-data-source>
  `,
})
export default class App {
  protected readonly dataSource = dataSource;
  protected readonly columns = columns;
  protected readonly getContextMenuItems = getContextMenuItems;
}
```

This function can also return a `Promise` that resolves to one of the above types. This is useful for lazy loading the context menu items.

When returning a `Promise`, the context menu will be shown after the promise resolves, and the default browser context menu is not shown.

### getColumnMenuItems (`(items, context) => MenuItem[]`)

> Allows customization of the context menu items for a column.

Use this function to customize the context menu for columns. The function is called with the following arguments:

- `items` - the default menu items for the column - you can return this array as is to use the default menu items (same as not providing this function prop) or you can customize the array or return a new one altogether.
- `context` - an object that gives you access to the column and the grid state
  - `context.column: InfiniteTableComputedColumn<T>` - the current column for which the context menu is being shown
  - `context.api` - a reference to the [api](https://infinite-table.com/docs/reference/api/index.md)

In this example, the currency and preferredLanguage columns have a custom icon for triggering the column context menu.

In addition, the `preferredLanguage` column has a custom header that shows a button for triggering the column context menu.

**Example: getColumnMenuItems example - custom menu item and icon**

```ts
import { Component, TemplateRef, viewChild } from '@angular/core';

import {
  DataSource,
  InfiniteTable,
  renderTemplate,
} from '@infinite-table/infinite-angular';
import type {
  InfiniteTablePropColumns,
  InfiniteTablePropGetColumnMenuItems,
} from '@infinite-table/infinite-angular';

type Developer = {
  id: number;
  firstName: string;
  lastName: string;
  country: string;
  city: string;
  currency: string;
  preferredLanguage: string;
  stack: string;
  canDesign: 'yes' | 'no';
  hobby: string;
  salary: number;
  age: number;
};

const dataSource = () => {
  return fetch(process.env.NEXT_PUBLIC_BASE_URL + '/developers1k')
    .then((r) => r.json())
    .then((data: Developer[]) => data);
};

const getColumnMenuItems: InfiniteTablePropGetColumnMenuItems<Developer> = (
  items,
  { column },
) => {
  if (column.id === 'firstName') {
    // you can adjust the default items for a specific column
    items.splice(0, 0, {
      key: 'firstName',
      label: 'First name menu item',
      onAction: () => {
        console.log('Hey there!');
      },
    });
  }

  items.push(
    {
      key: 'hello',
      label: 'Hello World',
      onAction: () => {
        alert('Hello World from column ' + column.id);
      },
    },
    {
      key: 'translate',
      label: 'Translate',
      menu: {
        items: [
          {
            key: 'translateToEnglish',
            label: 'English',
            onAction: () => {
              console.log('Translate to English');
            },
          },
          {
            key: 'translateToFrench',
            label: 'French',
            onAction: () => {
              console.log('Translate to French');
            },
          },
        ],
      },
    },
  );
  return items;
};

@Component({
  selector: 'demo-root',
  imports: [DataSource, InfiniteTable],
  template: `
    <infinite-data-source primaryKey="id" [data]="dataSource">
      <infinite-table
        debugId="getColumnMenuItems-example"
        [columnHeaderHeight]="70"
        [columns]="columns"
        [getColumnMenuItems]="getColumnMenuItems"
      />
    </infinite-data-source>

    <!-- custom menu icon -->
    <ng-template #globe>
      <div>🌎</div>
    </ng-template>

    
    <ng-template #languageHeader let-columnApi="columnApi">
      Preferred Language
      <!-- stop the propagation of pointerdown, so a click on the button doesn't sort the column, and of mousedown, so the menu is not closed automatically: the button toggles it -->
      <button
        style="border: 1px solid magenta; margin: 2px"
        (pointerdown)="$event.stopPropagation()"
        (mousedown)="
          $event.stopPropagation(); columnApi.toggleContextMenu($event.target)
        "
      >
        Toggle menu
      </button>
    </ng-template>
  `,
})
export default class App {
  protected readonly dataSource = dataSource;
  protected readonly getColumnMenuItems = getColumnMenuItems;

  private readonly globeTemplate =
    viewChild.required<TemplateRef<unknown>>('globe');
  private readonly languageHeaderTemplate =
    viewChild.required<TemplateRef<unknown>>('languageHeader');

  protected readonly columns: InfiniteTablePropColumns<Developer> = {
    currency: {
      field: 'currency',

      // custom menu icon
      renderMenuIcon: () => this.globeTemplate(),
    },

    preferredLanguage: {
      field: 'preferredLanguage',
      defaultWidth: 350,
      header: ({ columnApi, renderLocation }) => {
        // if we're inside the column menu with all columns, return only the col name
        if (renderLocation === 'column-menu') {
          return 'Preferred Language';
        }

        // but for the real column header
        // return this custom content
        return renderTemplate(this.languageHeaderTemplate(), { columnApi });
      },

      // custom menu icon
      renderMenuIcon: () => this.globeTemplate(),
    },
    salary: {
      field: 'salary',
      // hide the menu icon
      renderMenuIcon: false,
    },
    country: {
      field: 'country',
    },
    id: { field: 'id', defaultWidth: 80, renderMenuIcon: false },
    firstName: {
      field: 'firstName',
    },
  };
}
```

### groupColumn (`InfiniteTableColumn|(colInfo, toggleGroupRow) => InfiniteTableColumn`)

> Allows you to define a custom configuration for one or multiple group columns. When this prop is defined, it gets merged onto any values specified in the [`groupBy.column`](https://infinite-table.com/angular/docs/reference/datasource-props/index.md#groupBy.column) property.

If this is an object and no explicit [`groupRenderStrategy`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#groupRenderStrategy) is specified, the component is rendered as if you had [groupRenderStrategy="single-column"](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#groupRenderStrategy).

If it's a function, it will be called with the following arguments:

- `colInfo` - an object with the following properties:
- `colInfo.groupCount` - the count of row groups
- `colInfo.groupBy` - the array of row groups, used by the `DataSource` to do the grouping
- `colInfo.groupRenderStrategy` - the current [render strategy for groups](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#groupRenderStrategy).
- `colInfo.groupByForColumn` - the grouping object (one of the items in `colInfo.groupBy`) corresponding to the current column. Only defined when `groupRenderStrategy` is `multi-column`.
- `colInfo.groupIndexForColumn` - the index of `colInfo.groupByForColumn` in `colInfo.groupBy` - corresponding to the current column. Only defined when `groupRenderStrategy` is `multi-column`.
- `toggleGroupRow(groupKeys: any[])` - a function you can use to toggle a group row. Pass an array of keys - the path to the group row you want to toggle.

You can still use [`groupColumn`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#groupColumn) as a function with single column group render strategy, but in this case, you have to be explicit and specify [groupRenderStrategy="single-column"](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#groupRenderStrategy).

**Example: groupColumn used as an object**

```ts
import { Component } from '@angular/core';

import { DataSource, InfiniteTable } from '@infinite-table/infinite-angular';
import type {
  DataSourcePropGroupBy,
  InfiniteTableColumn,
  InfiniteTablePropColumns,
} from '@infinite-table/infinite-angular';

type Developer = {
  id: number;
  firstName: string;
  lastName: string;
  country: string;
  city: string;
  currency: string;
  email: string;
  preferredLanguage: string;
  stack: string;
  canDesign: 'yes' | 'no';
  hobby: string;
  salary: number;
  age: number;
};

const groupBy: DataSourcePropGroupBy<Developer> = [
  {
    field: 'stack',
  },
  {
    field: 'preferredLanguage',
  },
];

const columns: InfiniteTablePropColumns<Developer> = {
  country: {
    field: 'country',
  },
  firstName: {
    field: 'firstName',
    style: {
      color: 'orange',
    },
    renderValue: ({ value, rowInfo }) =>
      rowInfo.isGroupRow ? null : `${value}.`,
  },
  stack: {
    field: 'stack',
    style: {
      color: 'tomato',
    },
  },
  age: { field: 'age' },
  salary: {
    field: 'salary',
    type: 'number',
  },
  canDesign: { field: 'canDesign' },
};

const groupColumn: InfiniteTableColumn<Developer> = {
  field: 'firstName',
  renderValue: ({ value }) => {
    return `First name: ${value}`;
  },
};

const dataSource = () => {
  return fetch(process.env.NEXT_PUBLIC_BASE_URL + '/developers1k')
    .then((r) => r.json())
    .then((data: Developer[]) => data);
};

@Component({
  selector: 'demo-root',
  imports: [DataSource, InfiniteTable],
  template: `
    <infinite-data-source [data]="dataSource" primaryKey="id" [groupBy]="groupBy">
      <infinite-table
        debugId="group-column-custom-renderers-example"
        [groupColumn]="groupColumn"
        [columns]="columns"
        [columnDefaultWidth]="250"
      />
    </infinite-data-source>
  `,
})
export default class App {
  protected readonly dataSource = dataSource;
  protected readonly columns = columns;
  protected readonly groupBy = groupBy;
  protected readonly groupColumn = groupColumn;
}
```

This example shows how to use [`groupColumn`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#groupColumn) as a function that allows you to customize all generated group columns in a single place.

**Example: groupColumn used as a function**

```ts
import { Component } from '@angular/core';

import { DataSource, InfiniteTable } from '@infinite-table/infinite-angular';
import type {
  DataSourcePropGroupBy,
  InfiniteTableColumn,
  InfiniteTablePropColumns,
} from '@infinite-table/infinite-angular';

type Developer = {
  id: number;
  firstName: string;
  lastName: string;
  country: string;
  city: string;
  currency: string;
  email: string;
  preferredLanguage: string;
  stack: string;
  canDesign: 'yes' | 'no';
  hobby: string;
  salary: number;
  age: number;
};

const groupBy: DataSourcePropGroupBy<Developer> = [
  {
    field: 'stack',
  },
  {
    field: 'preferredLanguage',
  },
];

const columns: InfiniteTablePropColumns<Developer> = {
  country: {
    field: 'country',
  },
  firstName: {
    field: 'firstName',
    style: {
      color: 'orange',
    },
    renderValue: ({ value, rowInfo }) =>
      rowInfo.isGroupRow ? null : `${value}.`,
  },
  stack: {
    field: 'stack',
    style: {
      color: 'tomato',
    },
  },
  age: { field: 'age' },
  salary: {
    field: 'salary',
    type: 'number',
  },
  canDesign: { field: 'canDesign' },
};

const groupColumn: InfiniteTableColumn<Developer> = {
  field: 'firstName',
  renderValue: ({ value }) => {
    return `First name: ${value}`;
  },
};

const dataSource = () => {
  return fetch(process.env.NEXT_PUBLIC_BASE_URL + '/developers1k')
    .then((r) => r.json())
    .then((data: Developer[]) => data);
};

@Component({
  selector: 'demo-root',
  imports: [DataSource, InfiniteTable],
  template: `
    <infinite-data-source [data]="dataSource" primaryKey="id" [groupBy]="groupBy">
      <infinite-table
        debugId="group-column-custom-renderers-example"
        [groupColumn]="groupColumn"
        [columns]="columns"
        [columnDefaultWidth]="250"
      />
    </infinite-data-source>
  `,
})
export default class App {
  protected readonly dataSource = dataSource;
  protected readonly columns = columns;
  protected readonly groupBy = groupBy;
  protected readonly groupColumn = groupColumn;
}
```

### groupRenderStrategy (`'single-column'|'multi-column'`)

> Determines how grouping is rendered - whether a single or multiple columns are generated.

```ts
import { Component, signal } from '@angular/core';

import { DataSource, InfiniteTable } from '@infinite-table/infinite-angular';
import type {
  DataSourcePropGroupBy,
  InfiniteTableGroupColumnFunction,
  InfiniteTablePropGroupRenderStrategy,
} from '@infinite-table/infinite-angular';

import { columns } from './employee-columns.angular';
import type { Employee } from './employee-columns.angular';

const groupBy: DataSourcePropGroupBy<Employee> = [
  {
    field: 'age',
  },
  {
    field: 'companyName',
  },
];

const groupColumn: InfiniteTableGroupColumnFunction<Employee> = (options) => {
  const field = options.groupByForColumn?.field;
  const groupColumn = {
    width: field === 'age' ? 160 : 250,
    header: field === 'age' ? '🎊 Age' : '🎉 Company',
    renderValue: ({ value }: { value: any }) => {
      if (field === 'age') {
        return `Age: ${value}`;
      }

      return value;
    },
  };

  return groupColumn;
};

const domProps = {
  style: { flex: 1 },
};

const dataSource = () => {
  return fetch(process.env.NEXT_PUBLIC_BASE_URL + '/employees1k')
    .then((r) => r.json())
    .then((data: Employee[]) => data);
};

@Component({
  selector: 'demo-root',
  imports: [DataSource, InfiniteTable],
  template: `
    <div
      style="
        display: flex;
        flex: 1;
        color: var(--infinite-cell-color);
        flex-flow: column;
        background: var(--infinite-background);
      "
    >
      <p style="padding: 10px">Please select the group render strategy</p>
      <div style="padding: 10px">
        <select
          style="
            margin: 10px 0;
            display: inline-block;
            background: var(--infinite-background);
            color: currentColor;
            padding: var(--infinite-space-3);
          "
          [value]="groupRenderStrategy()"
          (change)="onStrategyChange($event)"
        >
          <option value="multi-column">multi-column</option>
          <option value="single-column">single-column</option>
        </select>
      </div>
      <infinite-data-source
        [data]="dataSource"
        primaryKey="id"
        [groupBy]="groupBy"
      >
        <infinite-table
          debugId="groupRenderStrategy-example"
          [domProps]="domProps"
          [groupRenderStrategy]="groupRenderStrategy()"
          [groupColumn]="groupColumn"
          [columns]="columns"
          [columnDefaultWidth]="150"
        />
      </infinite-data-source>
    </div>
  `,
})
export default class App {
  protected readonly dataSource = dataSource;
  protected readonly columns = columns;
  protected readonly groupBy = groupBy;
  protected readonly groupColumn = groupColumn;
  protected readonly domProps = domProps;

  protected readonly groupRenderStrategy =
    signal<InfiniteTablePropGroupRenderStrategy>('multi-column');

  protected onStrategyChange(event: Event) {
    const groupRenderStrategy = (event.target as HTMLSelectElement)
      .value as InfiniteTablePropGroupRenderStrategy;

    this.groupRenderStrategy.set(groupRenderStrategy);
  }
}
```

### hideColumnWhenGrouped (`boolean`)

> Allows you to hide group columns bound to fields that are grouped by (fields mentioned in [groupBy.field](https://infinite-table.com/angular/docs/reference/datasource-props/index.md#groupBy)).

In this example, toggle the checkbox to see the `stack` and `preferredLanguage` columns hide/show as the value of `hideColumnWhenGrouped` changes.

```ts
import { Component, signal } from '@angular/core';

import { DataSource, InfiniteTable } from '@infinite-table/infinite-angular';
import type {
  DataSourcePropGroupBy,
  InfiniteTablePropColumns,
} from '@infinite-table/infinite-angular';

type Developer = {
  id: number;
  firstName: string;
  lastName: string;
  country: string;
  city: string;
  currency: string;
  email: string;
  preferredLanguage: string;
  stack: string;
  canDesign: 'yes' | 'no';
  hobby: string;
  salary: number;
  age: number;
};

const groupBy: DataSourcePropGroupBy<Developer> = [
  {
    field: 'stack',
  },
  {
    field: 'preferredLanguage',
  },
];

const columns: InfiniteTablePropColumns<Developer> = {
  country: {
    field: 'country',
  },
  firstName: {
    field: 'firstName',
  },
  preferredLanguage: {
    field: 'preferredLanguage',
  },
  stack: {
    field: 'stack',
    style: {
      color: 'tomato',
    },
  },
  age: { field: 'age' },
  salary: {
    field: 'salary',
    type: 'number',
  },
  canDesign: { field: 'canDesign' },
};

const groupColumn = {
  field: 'firstName' as keyof Developer,
};

const domProps = {
  style: { flex: 1 },
};

const dataSource = () => {
  return fetch(process.env.NEXT_PUBLIC_BASE_URL + '/developers1k')
    .then((r) => r.json())
    .then((data: Developer[]) => data);
};

@Component({
  selector: 'demo-root',
  imports: [DataSource, InfiniteTable],
  template: `
    <div
      style="
        display: flex;
        flex: 1;
        color: var(--infinite-cell-color);
        flex-flow: column;
        background: var(--infinite-background);
      "
    >
      <div style="padding: 10px">
        <label>
          <input
            type="checkbox"
            [checked]="hideColumnWhenGrouped()"
            (change)="hideColumnWhenGrouped.set(!hideColumnWhenGrouped())"
          />Hide Column When Grouped
        </label>
      </div>
      <infinite-data-source
        [data]="dataSource"
        primaryKey="id"
        [groupBy]="groupBy"
      >
        <infinite-table
          debugId="hideColumnWhenGrouped-example"
          [groupColumn]="groupColumn"
          [columns]="columns"
          [hideColumnWhenGrouped]="hideColumnWhenGrouped()"
          [columnDefaultWidth]="250"
          [domProps]="domProps"
        />
      </infinite-data-source>
    </div>
  `,
})
export default class App {
  protected readonly dataSource = dataSource;
  protected readonly columns = columns;
  protected readonly groupBy = groupBy;
  protected readonly groupColumn = groupColumn;
  protected readonly domProps = domProps;

  protected readonly hideColumnWhenGrouped = signal(true);
}
```

### hideEmptyGroupColumns (`boolean`)

> Allows you to hide group columns which don't render any information (this happens when all previous groups are collapsed).

```ts
import { Component, signal } from '@angular/core';

import { DataSource, InfiniteTable } from '@infinite-table/infinite-angular';
import type {
  DataSourcePropGroupBy,
  DataSourcePropGroupRowsState,
  InfiniteTablePropColumns,
} from '@infinite-table/infinite-angular';

type Developer = {
  id: number;
  firstName: string;
  lastName: string;
  country: string;
  city: string;
  currency: string;
  email: string;
  preferredLanguage: string;
  stack: string;
  canDesign: 'yes' | 'no';
  hobby: string;
  salary: number;
  age: number;
};

const groupBy: DataSourcePropGroupBy<Developer> = [
  {
    field: 'stack',
  },
  {
    field: 'preferredLanguage',
  },
];

const domProps = {
  style: { flex: 1 },
};

const groupRowsState: DataSourcePropGroupRowsState = {
  expandedRows: [],
  collapsedRows: true,
};

const columns: InfiniteTablePropColumns<Developer> = {
  country: {
    field: 'country',
  },
  firstName: { field: 'firstName' },
  age: { field: 'age' },
  salary: {
    field: 'salary',
    type: 'number',
  },
  canDesign: { field: 'canDesign' },
  stack: { field: 'stack' },
};

const dataSource = () => {
  return fetch(process.env.NEXT_PUBLIC_BASE_URL + '/developers10')
    .then((r) => r.json())
    .then((data: Developer[]) => data);
};

@Component({
  selector: 'demo-root',
  imports: [DataSource, InfiniteTable],
  template: `
    <div
      style="
        display: flex;
        flex: 1;
        color: var(--infinite-cell-color);
        flex-flow: column;
        background: var(--infinite-background);
      "
    >
      <div style="padding: 10px">
        <label>
          <input
            type="checkbox"
            [checked]="hideEmptyGroupColumns()"
            (change)="hideEmptyGroupColumns.set(!hideEmptyGroupColumns())"
          />
          Hide Empty Group Columns (make sure all \`Stack\` groups are
          collapsed to see it in action). Try to expand the group column to see
          the new group column being added on-the-fly.
        </label>
      </div>
      <infinite-data-source
        [data]="dataSource"
        primaryKey="id"
        [defaultGroupRowsState]="groupRowsState"
        [groupBy]="groupBy"
      >
        <infinite-table
          debugId="hideEmptyGroupColumns-example"
          [domProps]="domProps"
          [hideEmptyGroupColumns]="hideEmptyGroupColumns()"
          groupRenderStrategy="multi-column"
          [columns]="columns"
          [columnDefaultWidth]="250"
        />
      </infinite-data-source>
    </div>
  `,
})
export default class App {
  protected readonly dataSource = dataSource;
  protected readonly columns = columns;
  protected readonly groupBy = groupBy;
  protected readonly groupRowsState = groupRowsState;
  protected readonly domProps = domProps;

  protected readonly hideEmptyGroupColumns = signal(true);
}
```

### keyboardNavigation (`'cell'|'row'|false`)

> Determines whether keyboard navigation is enabled.

Available values:

- `'cell'` - enables keyboard navigation for cells. This is the default.
- `'row'` - enables keyboard navigation for rows.
- `false` - disables keyboard navigation.

For cell keyboard navigation, see [`[(activeCellIndex)]`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#activeCellIndex).
For row keyboard navigation, see [`[(activeRowIndex)]`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#activeRowIndex).

This example starts with cell `[2,0]` already active.

**Example: Keyboard navigation**

```ts
import { Component } from '@angular/core';

import { InfiniteTable, DataSource } from '@infinite-table/infinite-angular';
import type {
  DataSourceData,
  InfiniteTablePropColumns,
} from '@infinite-table/infinite-angular';

type Developer = {
  id: number;
  firstName: string;
  lastName: string;
  country: string;
  city: string;
  currency: string;
  preferredLanguage: string;
  stack: string;
  canDesign: 'yes' | 'no';
  hobby: string;
  salary: number;
  age: number;
};

const dataSource: DataSourceData<Developer> = () => {
  return fetch(process.env.NEXT_PUBLIC_BASE_URL + `/developers1k-sql?`)
    .then((r) => r.json())
    .then((data: Developer[]) => data);
};

const columns: InfiniteTablePropColumns<Developer> = {
  preferredLanguage: { field: 'preferredLanguage' },
  country: { field: 'country' },
  salary: {
    field: 'salary',
    type: 'number',
  },
  age: { field: 'age' },
  canDesign: { field: 'canDesign' },
  firstName: { field: 'firstName' },
  stack: { field: 'stack' },
  id: { field: 'id' },
  hobby: { field: 'hobby' },
  city: { field: 'city' },
  currency: { field: 'currency' },
};

@Component({
  selector: 'demo-root',
  imports: [DataSource, InfiniteTable],
  template: `
    <infinite-data-source primaryKey="id" [data]="dataSource">
      <infinite-table
        debugId="navigating-cells-uncontrolled-example"
        [defaultActiveCellIndex]="[2, 0]"
        [columns]="columns"
      />
    </infinite-data-source>
  `,
})
export default class App {
  protected readonly dataSource = dataSource;
  protected readonly columns = columns;
}
```

In this example the keyboard navigation is disabled.

**Example: Disabled Keyboard navigation**

```ts
import { Component } from '@angular/core';

import { DataSource, InfiniteTable } from '@infinite-table/infinite-angular';
import type {
  DataSourceData,
  InfiniteTablePropColumns,
} from '@infinite-table/infinite-angular';

type Developer = {
  id: number;
  firstName: string;
  lastName: string;
  country: string;
  city: string;
  currency: string;
  preferredLanguage: string;
  stack: string;
  canDesign: 'yes' | 'no';
  hobby: string;
  salary: number;
  age: number;
};

const dataSource: DataSourceData<Developer> = () => {
  return fetch(
    'https://infinite-table.com/.netlify/functions/json-server' +
      `/developers1k-sql?`,
  )
    .then((r) => r.json())
    .then((data: Developer[]) => data);
};

const columns: InfiniteTablePropColumns<Developer> = {
  preferredLanguage: { field: 'preferredLanguage' },
  country: { field: 'country' },
  salary: {
    field: 'salary',
    type: 'number',
  },
  age: { field: 'age' },
  canDesign: { field: 'canDesign' },
  firstName: { field: 'firstName' },
  stack: { field: 'stack' },
  id: { field: 'id' },
  hobby: { field: 'hobby' },
  city: { field: 'city' },
  currency: { field: 'currency' },
};

@Component({
  selector: 'demo-root',
  imports: [DataSource, InfiniteTable],
  template: `
    <infinite-data-source primaryKey="id" [data]="dataSource">
      <infinite-table
        debugId="navigation-disabled-example"
        [keyboardNavigation]="false"
        [columns]="columns"
      />
    </infinite-data-source>
  `,
})
export default class App {
  protected readonly dataSource = dataSource;
  protected readonly columns = columns;
}
```

### keyboardSelection (`boolean`)

> Determines whether the keyboard can be used for selecting/deselecting rows/cells.

By default [`keyboardSelection`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#keyboardSelection) is enabled, so you can use the keyboard **spacebar** key to select multiple rows. Using the spacebar key is equivalent to doing a mouse click, so expect the combination of **spacebar** + `cmd`/`ctrl`/`shift` modifier keys to behave just like clicking + the same modifier keys.

For specifying the selection mode, use [`selectionMode`](https://infinite-table.com/angular/docs/reference/datasource-props/index.md#selectionMode)

**Example: Toggling keyboard navigation**

```ts
import { Component, signal } from '@angular/core';

import { DataSource, InfiniteTable } from '@infinite-table/infinite-angular';
import type { InfiniteTablePropColumns } from '@infinite-table/infinite-angular';

type Developer = {
  id: number;
  firstName: string;
  lastName: string;
  country: string;
  city: string;
  currency: string;
  email: string;
  preferredLanguage: string;
  stack: string;
  canDesign: 'yes' | 'no';
  hobby: string;
  salary: number;
  age: number;
};

const columns: InfiniteTablePropColumns<Developer> = {
  country: {
    field: 'country',
  },
  firstName: {
    field: 'firstName',
  },
  stack: {
    field: 'stack',
  },
  age: { field: 'age' },
  id: { field: 'id' },
  salary: {
    field: 'salary',
    type: 'number',
  },
  canDesign: { field: 'canDesign' },
};

const dataSource = () => {
  return fetch(process.env.NEXT_PUBLIC_BASE_URL + '/developers100')
    .then((r) => r.json())
    .then((data: Developer[]) => data);
};

@Component({
  selector: 'demo-root',
  imports: [DataSource, InfiniteTable],
  template: `
    <div style="color: var(--infinite-cell-color); padding: 10px">
      Keyboard selection is now
      <b>{{ keyboardSelection() ? 'enabled' : 'disabled' }}</b>.
      <button
        style="border: 1px solid tomato; display: block; padding: 5px; margin-top: 10px"
        (click)="keyboardSelection.set(!keyboardSelection())"
      >
        Click to toggle keyboard selection
      </button>
    </div>
    <infinite-data-source [data]="dataSource" selectionMode="multi-row" primaryKey="id">
      <infinite-table
        debugId="default-selection-mode-multi-row-keyboard-toggle-example"
        [keyboardSelection]="keyboardSelection()"
        [columns]="columns"
        [columnDefaultWidth]="150"
      />
    </infinite-data-source>
  `,
})
export default class App {
  protected readonly dataSource = dataSource;
  protected readonly columns = columns;

  protected readonly keyboardSelection = signal(true);
}
```

### loadingText (`ReactNode`)

> The text inside the load mask - displayed when [loading=true](https://infinite-table.com/angular/docs/reference/datasource-props/index.md#loading).

**Example: Customized loading text**

```ts
import { Component } from '@angular/core';

import { DataSource, InfiniteTable } from '@infinite-table/infinite-angular';
import type { InfiniteTableColumn } from '@infinite-table/infinite-angular';

type Employee = {
  id: string | number;
  name: string;
  salary: number;
  department: string;
  company: string;
};

const employees: Employee[] = [
  {
    id: 1,
    name: 'Bob',
    salary: 10_000,
    department: 'IT',
    company: 'Bobsons',
  },
  {
    id: 2,
    name: 'Alice',
    salary: 20_000,
    department: 'IT',
    company: 'Bobsons',
  },
];

const columns: Record<string, InfiniteTableColumn<Employee>> = {
  id: {
    field: 'id',
    type: 'number',
    defaultWidth: 80,
  },
  name: {
    field: 'name',
  },
  salary: { field: 'salary', type: 'number' },
  department: { field: 'department', header: 'Dep.' },
  company: { field: 'company' },
};

@Component({
  selector: 'demo-root',
  imports: [DataSource, InfiniteTable],
  template: `
    <infinite-data-source [loading]="true" [data]="employees" primaryKey="id">
      <infinite-table
        debugId="loadingText-example"
        loadingText="Please wait ..."
        [columnDefaultWidth]="130"
        [columns]="columns"
      />
    </infinite-data-source>
  `,
})
export default class App {
  protected readonly employees = employees;
  protected readonly columns = columns;
}
```

### menuConstrainTo (`HTMLElement | () => HTMLElement | null`)

> The area the table menus are kept within - the column menu, the context menus and the filter operator menu. Defaults to the table element.

When a function is given, it's called every time a menu is shown. Returning `null` uses the table element.

Use it together with [`menuPortalContainer`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#menuPortalContainer) to let menus extend past the table, for example when the table sits in a pane that clips its content.

**Example: Menus rendered into document.body and kept within the app**

```ts
import { Component, ElementRef, viewChild } from '@angular/core';

import { DataSource, InfiniteTable } from '@infinite-table/infinite-angular';
import type { InfiniteTablePropColumns } from '@infinite-table/infinite-angular';

type Developer = {
  id: number;
  firstName: string;
  lastName: string;
  age: number;
};

const data: Developer[] = [
  { id: 1, firstName: 'John', lastName: 'Bob', age: 20 },
  { id: 2, firstName: 'Marry', lastName: 'Bob', age: 25 },
  { id: 3, firstName: 'Bill', lastName: 'Bobson', age: 30 },
];

const columns: InfiniteTablePropColumns<Developer> = {
  firstName: { field: 'firstName' },
  lastName: { field: 'lastName' },
  age: { field: 'age', type: 'number' },
};

@Component({
  selector: 'demo-root',
  imports: [DataSource, InfiniteTable],
  template: `
    <div
      #app
      style="
        display: flex;
        flex-direction: column;
        height: 100%;
        color: var(--infinite-cell-color);
      "
    >
      <p style="padding: 10px">
        The table sits in a short pane that clips its content. Open a column
        menu - it is rendered into document.body and kept within this app.
      </p>
      <div style="height: 360px; overflow: hidden">
        <infinite-data-source [data]="data" primaryKey="id">
          <infinite-table
            [columns]="columns"
            [menuPortalContainer]="menuPortalContainer"
            [menuConstrainTo]="menuConstrainTo"
          />
        </infinite-data-source>
      </div>
    </div>
  `,
})
export default class App {
  protected readonly data = data;
  protected readonly columns = columns;

  private readonly app = viewChild.required<ElementRef<HTMLElement>>('app');

  protected readonly menuPortalContainer = document.body;
  protected readonly menuConstrainTo = () => this.app().nativeElement;
}
```

### menuPortalContainer (`HTMLElement | () => HTMLElement | null`)

> The element the table menus are rendered into - the column menu, the context menus and the filter operator menu. Defaults to an element inside the table.

When a function is given, returning `null` uses the default element. Submenus are rendered into the same element.

Menus rendered inside the table can't extend past an ancestor that clips its content (`overflow: hidden`) - render them into an element outside that ancestor, such as `document.body`. They are still kept within the table area, unless you also specify [`menuConstrainTo`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#menuConstrainTo).

**Example: Menus rendered into document.body and kept within the app**

```ts
import { Component, ElementRef, viewChild } from '@angular/core';

import { DataSource, InfiniteTable } from '@infinite-table/infinite-angular';
import type { InfiniteTablePropColumns } from '@infinite-table/infinite-angular';

type Developer = {
  id: number;
  firstName: string;
  lastName: string;
  age: number;
};

const data: Developer[] = [
  { id: 1, firstName: 'John', lastName: 'Bob', age: 20 },
  { id: 2, firstName: 'Marry', lastName: 'Bob', age: 25 },
  { id: 3, firstName: 'Bill', lastName: 'Bobson', age: 30 },
];

const columns: InfiniteTablePropColumns<Developer> = {
  firstName: { field: 'firstName' },
  lastName: { field: 'lastName' },
  age: { field: 'age', type: 'number' },
};

@Component({
  selector: 'demo-root',
  imports: [DataSource, InfiniteTable],
  template: `
    <div
      #app
      style="
        display: flex;
        flex-direction: column;
        height: 100%;
        color: var(--infinite-cell-color);
      "
    >
      <p style="padding: 10px">
        The table sits in a short pane that clips its content. Open a column
        menu - it is rendered into document.body and kept within this app.
      </p>
      <div style="height: 360px; overflow: hidden">
        <infinite-data-source [data]="data" primaryKey="id">
          <infinite-table
            [columns]="columns"
            [menuPortalContainer]="menuPortalContainer"
            [menuConstrainTo]="menuConstrainTo"
          />
        </infinite-data-source>
      </div>
    </div>
  `,
})
export default class App {
  protected readonly data = data;
  protected readonly columns = columns;

  private readonly app = viewChild.required<ElementRef<HTMLElement>>('app');

  protected readonly menuPortalContainer = document.body;
  protected readonly menuConstrainTo = () => this.app().nativeElement;
}
```

### multiRowSelectionWith (`'checkbox'|'click'`)

> Decides whether clicking a row selects it, when [`selectionMode`](https://infinite-table.com/angular/docs/reference/datasource-props/index.md#selectionMode) is `'multi-row'`.

- `'checkbox'` (the default) - while a visible column shows a selection checkbox (see [renderSelectionCheckBox](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#columns.renderSelectionCheckBox)), users select rows with the checkboxes and the spacebar (`shift` + checkbox click and `shift` + spacebar select a range). Clicking a row doesn't change the selection. When no visible column shows a selection checkbox, it works like `'click'`.
- `'click'` - clicking a row selects it, with `cmd`/`ctrl` and `shift` as modifier keys, just like in the MacOS Finder app. The spacebar works like a click, and the selection checkboxes, if any, work as well.

Both values work the same with or without grouping, and with tree data - clicking a group row or a parent node selects (or with `cmd`/`ctrl`, toggles) the whole group or node. See [selecting a range of rows with groups](https://infinite-table.com/angular/docs/learn/selection/row-selection.md#selecting-a-range-of-rows-with-groups) for how `shift` ranges handle group rows.

**Example: Choosing how users select rows**

```ts
import { Component, signal } from '@angular/core';

import {
  DataSource,
  GroupRowsState,
  InfiniteTable,
} from '@infinite-table/infinite-angular';
import type {
  DataSourcePropGroupBy,
  DataSourcePropRowSelection,
  DataSourcePropRowSelection_MultiRow,
  InfiniteTableApi,
  InfiniteTablePropColumns,
  InfiniteTablePropMultiRowSelectionWith,
} from '@infinite-table/infinite-angular';

type Developer = {
  id: number;
  name: string;
  language: string;
};

const data: Developer[] = [
  { id: 1, name: 'TS 1', language: 'TypeScript' },
  { id: 2, name: 'TS 2', language: 'TypeScript' },
  { id: 3, name: 'TS 3', language: 'TypeScript' },
  { id: 4, name: 'Go 1', language: 'Go' },
  { id: 5, name: 'Go 2', language: 'Go' },
  { id: 6, name: 'Rust 1', language: 'Rust' },
  { id: 7, name: 'Rust 2', language: 'Rust' },
  { id: 8, name: 'Rust 3', language: 'Rust' },
];

const columns: InfiniteTablePropColumns<Developer> = {
  name: { field: 'name' },
  language: { field: 'language' },
};

const groupBy: DataSourcePropGroupBy<Developer> = [{ field: 'language' }];

// the Go group starts collapsed
const defaultGroupRowsState = new GroupRowsState({
  expandedRows: true,
  collapsedRows: [['Go']],
});

@Component({
  selector: 'demo-root',
  imports: [DataSource, InfiniteTable],
  template: `
    <div
      style="
        color: var(--infinite-cell-color);
        padding: 10px;
        display: flex;
        gap: 20px;
        align-items: center;
      "
    >
      <label>
        multiRowSelectionWith:
        <select [value]="selectWith()" (change)="onSelectWithChange($event)">
          <option value="click">click</option>
          <option value="checkbox">checkbox</option>
        </select>
      </label>
      <span>Selected: {{ selected().join(', ') || 'none' }}</span>
    </div>
    <infinite-data-source
      [data]="data"
      primaryKey="id"
      selectionMode="multi-row"
      [groupBy]="groupBy"
      [defaultGroupRowsState]="defaultGroupRowsState"
      (rowSelectionChange)="onRowSelectionChange($event)"
    >
      <infinite-table
        [columns]="columns"
        [columnDefaultWidth]="150"
        groupRenderStrategy="single-column"
        [multiRowSelectionWith]="selectWith()"
        (ready)="api = $event.api"
      />
    </infinite-data-source>
  `,
})
export default class App {
  protected readonly data = data;
  protected readonly columns = columns;
  protected readonly groupBy = groupBy;
  protected readonly defaultGroupRowsState = defaultGroupRowsState;

  protected readonly selectWith =
    signal<InfiniteTablePropMultiRowSelectionWith>('click');
  protected readonly selected = signal<string[]>([]);

  protected api: InfiniteTableApi<Developer> | null = null;

  protected onSelectWithChange(event: Event) {
    this.selectWith.set(
      (event.target as HTMLSelectElement)
        .value as InfiniteTablePropMultiRowSelectionWith,
    );
  }

  protected onRowSelectionChange(
    rowSelection: DataSourcePropRowSelection | undefined,
  ) {
    // selectionMode="multi-row": the selection is an object
    const ids = this.api?.rowSelectionApi.getSelectedPrimaryKeys(
      rowSelection as DataSourcePropRowSelection_MultiRow,
    );
    this.selected.set(
      data.filter((d) => ids?.includes(d.id)).map((d) => d.name),
    );
  }
}
```

### multiSortBehavior (`'append'|'replace'`)

> Specifies the behavior of the DataGrid when [multiple sorting](https://infinite-table.com/angular/docs/learn/sorting/multiple-sorting.md) is configured. Defaults to `'replace'`.

When `InfiniteTable` is configured with multiple sorting there are two supported behaviors:

- `append` - when this behavior is used, clicking a column header adds that column to the alredy existing sort. If the column is already sorted, the sort direction is reversed. In order to remove a column from the sort, the user needs to click the column header in order to toggle sorting from ascending to descending and then to no sorting.
- `replace` - the default behavior - a user clicking a column header removes any existing sorting and sets that column as sorted. In order to add a new column to the sort, the user needs to hold the `Ctrl/Cmd` key while clicking the column header.

Try clicking the `age` column and then the `firstName` column.

If the multi-sort behavior is `replace`, clicking the second column will remove the sort from the first column.
In order for the sorting to be additive, even if the behavior is `replace`, use the `Ctrl`/`Cmd` key while clicking the column header.

If the multi-sort behavior is `append`, clicking the second column will add it to the sort.

```ts
import { Component, signal } from '@angular/core';

import { DataSource, InfiniteTable } from '@infinite-table/infinite-angular';
import type {
  InfiniteTablePropColumns,
  InfiniteTablePropMultiSortBehavior,
} from '@infinite-table/infinite-angular';

type Developer = {
  id: number;
  firstName: string;
  country: string;
  city: string;
  currency: string;
  email: string;
  preferredLanguage: string;
  hobby: string;
  salary: number;
  age: number;
};

const columns: InfiniteTablePropColumns<Developer> = {
  firstName: { field: 'firstName', header: 'First Name' },
  age: { field: 'age', header: 'Age' },
  salary: {
    field: 'salary',
    header: 'Salary',
    type: 'number',
  },
  country: { field: 'country', header: 'Country' },
  preferredLanguage: { field: 'preferredLanguage' },
  id: { field: 'id' },
  hobby: { field: 'hobby' },
  city: { field: 'city' },
  currency: { field: 'currency' },
};

const dataSource: Developer[] = [
  {
    id: 0,
    firstName: 'Nya',
    country: 'India',
    city: 'Unnao',
    age: 24,
    currency: 'JPY',
    preferredLanguage: 'TypeScript',
    salary: 60000,
    hobby: 'sports',
    email: 'Nya44@gmail.com',
  },
  {
    id: 1,
    firstName: 'Axel',
    country: 'Mexico',
    city: 'Cuitlahuac',
    age: 46,
    currency: 'USD',
    preferredLanguage: 'TypeScript',
    salary: 100000,
    hobby: 'sports',
    email: 'Axel93@hotmail.com',
  },
  {
    id: 2,
    firstName: 'Gonzalo',
    country: 'United Arab Emirates',
    city: 'Fujairah',
    age: 24,
    currency: 'JPY',
    preferredLanguage: 'Go',
    salary: 120000,
    hobby: 'photography',
    email: 'Gonzalo_McGlynn34@gmail.com',
  },
  {
    id: 3,
    firstName: 'Sherwood',
    country: 'Mexico',
    city: 'Tlacolula de Matamoros',
    age: 24,
    currency: 'CHF',
    preferredLanguage: 'Rust',
    salary: 99000,
    hobby: 'cooking',
    email: 'Sherwood_McLaughlin65@hotmail.com',
  },
  {
    id: 4,
    firstName: 'Alexandre',
    country: 'France',
    city: 'Persan',
    age: 24,
    currency: 'EUR',
    preferredLanguage: 'Go',
    salary: 97000,
    hobby: 'reading',
    email: 'Alexandre_Harber@hotmail.com',
  },
  {
    id: 5,
    firstName: 'Mariane',
    country: 'United States',
    city: 'Hays',
    age: 23,
    currency: 'EUR',
    preferredLanguage: 'TypeScript',

    salary: 58000,
    hobby: 'cooking',
    email: 'Mariane0@hotmail.com',
  },
  {
    id: 6,
    firstName: 'Rosalind',
    country: 'Mexico',
    city: 'Nuevo Casas Grandes',
    age: 23,
    currency: 'AUD',
    preferredLanguage: 'JavaScript',
    salary: 198000,
    hobby: 'dancing',
    email: 'Rosalind69@gmail.com',
  },
  {
    id: 7,
    firstName: 'Lolita',
    country: 'Sweden',
    city: 'Delsbo',
    age: 22,
    currency: 'JPY',
    preferredLanguage: 'TypeScript',
    salary: 200000,
    hobby: 'cooking',
    email: 'Lolita.Hayes@hotmail.com',
  },
  {
    id: 8,
    firstName: 'Tre',
    country: 'Germany',
    city: 'Bad Camberg',
    age: 23,
    currency: 'GBP',
    preferredLanguage: 'TypeScript',
    salary: 200000,
    hobby: 'sports',
    email: 'Tre28@gmail.com',
  },
  {
    id: 9,
    firstName: 'Lurline',
    country: 'Canada',
    city: 'Raymore',
    age: 23,
    currency: 'EUR',
    preferredLanguage: 'Rust',
    salary: 58000,
    hobby: 'sports',
    email: 'Lurline_Deckow@gmail.com',
  },
];

@Component({
  selector: 'demo-root',
  imports: [DataSource, InfiniteTable],
  styles: `
    .toolbar {
      display: flex;
      flex-direction: row;
      background: var(--infinite-background);
      color: var(--infinite-cell-color);
    }
    .toolbar p {
      padding: 10px;
    }
    .toolbar select {
      margin: 10px 0;
      display: inline-block;
      background: var(--infinite-background);
      color: var(--infinite-cell-color);
      padding: var(--infinite-space-3);
    }
  `,
  template: `
    <div class="toolbar">
      <p>Select the multi-sort behavior</p>
      <select
        [value]="multiSortBehavior()"
        (change)="setMultiSortBehavior($event)"
      >
        <option value="replace">replace</option>
        <option value="append">append</option>
      </select>
    </div>
    <infinite-data-source primaryKey="id" [data]="dataSource" [defaultSortInfo]="[]">
      <infinite-table
        debugId="local-multi-sorting-example-defaults-with-local-data"
        [columns]="columns"
        [columnDefaultWidth]="120"
        [multiSortBehavior]="multiSortBehavior()"
      />
    </infinite-data-source>
  `,
})
export default class App {
  protected readonly dataSource = dataSource;
  protected readonly columns = columns;
  protected readonly multiSortBehavior =
    signal<InfiniteTablePropMultiSortBehavior>('replace');

  protected setMultiSortBehavior(event: Event) {
    this.multiSortBehavior.set(
      (event.target as HTMLSelectElement)
        .value as InfiniteTablePropMultiSortBehavior,
    );
  }
}
```

### onActiveCellIndexChange (`(activeCellIndex:[number,number])=>void`)

> Callback triggered by cell navigation. See the [Keyboard Navigation](https://infinite-table.com/angular/docs/learn/keyboard-navigation/navigating-cells.md) page for more details.

See related [`[(activeCellIndex)]`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#activeCellIndex) and [`keyboardNavigation`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#keyboardNavigation) for the keyboard navigation behavior.

This example uses `onActiveCellIndexChange` to react to changes in the `activeCellIndex`.

**Example: Controlled keyboard navigation (for cells) with callback**

```ts
import { Component, signal } from '@angular/core';

import { InfiniteTable, DataSource } from '@infinite-table/infinite-angular';
import type {
  DataSourceData,
  InfiniteTablePropColumns,
} from '@infinite-table/infinite-angular';

type Developer = {
  id: number;
  firstName: string;
  lastName: string;
  country: string;
  city: string;
  currency: string;
  preferredLanguage: string;
  stack: string;
  canDesign: 'yes' | 'no';
  hobby: string;
  salary: number;
  age: number;
};

const dataSource: DataSourceData<Developer> = () => {
  return fetch(
    'https://infinite-table.com/.netlify/functions/json-server' +
      `/developers1k-sql?`,
  )
    .then((r) => r.json())
    .then((data: Developer[]) => data);
};

const columns: InfiniteTablePropColumns<Developer> = {
  preferredLanguage: { field: 'preferredLanguage' },
  country: { field: 'country' },
  salary: {
    field: 'salary',
    type: 'number',
  },
  age: { field: 'age' },
  canDesign: { field: 'canDesign' },
  firstName: { field: 'firstName' },
  stack: { field: 'stack' },
  id: { field: 'id' },
  hobby: { field: 'hobby' },
  city: { field: 'city' },
  currency: { field: 'currency' },
};

@Component({
  selector: 'demo-root',
  imports: [DataSource, InfiniteTable],
  template: `
    <div style="color: var(--infinite-cell-color)">
      Current active cell: {{ activeCellIndex()[0] }}, {{ activeCellIndex()[1] }}.
    </div>
    <infinite-data-source primaryKey="id" [data]="dataSource">
      <infinite-table
        debugId="navigating-cells-controlled-example"
        [(activeCellIndex)]="activeCellIndex"
        [columns]="columns"
      />
    </infinite-data-source>
  `,
})
export default class App {
  protected readonly dataSource = dataSource;
  protected readonly columns = columns;

  
  protected readonly activeCellIndex = signal<[number, number]>([2, 0]);
}
```

### onActiveRowIndexChange (`(activeRowIndex:number)=>void`)

> Callback triggered by row navigation. See the [Keyboard Navigation](https://infinite-table.com/angular/docs/learn/keyboard-navigation/navigating-rows.md) page for more details.

See related [`[(activeRowIndex)]`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#activeRowIndex) and [`keyboardNavigation`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#keyboardNavigation) for the keyboard navigation behavior.

This example uses `onActiveRowIndexChange` to react to changes in the `activeRowIndex`.

**Example: Controlled keyboard navigation (for rows) with callback**

```ts
import { Component, signal } from '@angular/core';

import { InfiniteTable, DataSource } from '@infinite-table/infinite-angular';
import type {
  DataSourceData,
  InfiniteTablePropColumns,
} from '@infinite-table/infinite-angular';

type Developer = {
  id: number;
  firstName: string;
  lastName: string;
  country: string;
  city: string;
  currency: string;
  preferredLanguage: string;
  stack: string;
  canDesign: 'yes' | 'no';
  hobby: string;
  salary: number;
  age: number;
};

const dataSource: DataSourceData<Developer> = () => {
  return fetch(
    'https://infinite-table.com/.netlify/functions/json-server' +
      `/developers1k-sql?`,
  )
    .then((r) => r.json())
    .then((data: Developer[]) => data);
};

const columns: InfiniteTablePropColumns<Developer> = {
  preferredLanguage: { field: 'preferredLanguage' },
  country: { field: 'country' },
  salary: {
    field: 'salary',
    type: 'number',
  },
  age: { field: 'age' },
  canDesign: { field: 'canDesign' },
  firstName: { field: 'firstName' },
  stack: { field: 'stack' },
  id: { field: 'id' },
  hobby: { field: 'hobby' },
  city: { field: 'city' },
  currency: { field: 'currency' },
};

@Component({
  selector: 'demo-root',
  imports: [DataSource, InfiniteTable],
  template: `
    <div style="color: var(--infinite-cell-color)">
      Current active row: {{ activeRowIndex() }}.
    </div>
    <infinite-data-source primaryKey="id" [data]="dataSource">
      <infinite-table
        debugId="navigating-rows-controlled-example"
        keyboardNavigation="row"
        [(activeRowIndex)]="activeRowIndex"
        [columns]="columns"
      />
    </infinite-data-source>
  `,
})
export default class App {
  protected readonly dataSource = dataSource;
  protected readonly columns = columns;

  
  protected readonly activeRowIndex = signal(2);
}
```

### onBlurWithin (`(event)=> void`)

> Function that is called when a focused element is blurred within the component.

For the corresponding focus event, see [`(focusWithin)`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#onFocusWithin)

This callback is fired when a focusable element inside the component is blurred, and the focus is no longer within the component. In other words, when you navigate focusable elements inside the table, this callback is not fired.

**Example: Blur an input inside the table to see the callback fired**

```ts
import { Component, TemplateRef, viewChild } from '@angular/core';

import { DataSource, InfiniteTable } from '@infinite-table/infinite-angular';
import type { InfiniteTableColumn } from '@infinite-table/infinite-angular';

import { data } from './data';
import type { Person } from './data';

const focusedWithinStyle = {
  outline: '3px solid tomato',
};

@Component({
  selector: 'demo-root',
  imports: [DataSource, InfiniteTable],
  template: `
    <infinite-data-source [data]="data" primaryKey="Id">
      <infinite-table
        debugId="onBlurWithin-example"
        (blurWithin)="onBlurWithin()"
        [focusedWithinStyle]="focusedWithinStyle"
        [columns]="columns"
      />
    </infinite-data-source>

    <ng-template #inputCell let-value="value">
      <input type="text" [value]="value" />
    </ng-template>
  `,
})
export default class App {
  protected readonly data = data;
  protected readonly focusedWithinStyle = focusedWithinStyle;

  private readonly inputCell =
    viewChild.required<TemplateRef<unknown>>('inputCell');

  protected readonly columns: Record<string, InfiniteTableColumn<Person>> = {
    id: {
      field: 'Id',
      type: 'number',
      defaultSortable: true,
      defaultWidth: 80,
    },
    firstName: {
      field: 'FirstName',
      render: () => this.inputCell(),
    },
    age: { field: 'Age', type: 'number' },
  };

  protected onBlurWithin() {
    console.log('onBlurWithin');
  }
}
```

### onCellDoubleClick (`({ colIndex, rowIndex, column, columnApi, api, dataSourceApi }, event) => void | {preventEdit?: boolean} `)

> Callback function called when a cell has been double clicked.

If the cell is editable, you can prevent going into edit mode by returning `{preventEdit: true}` from the function.

### onCellClick (`({ colIndex, rowIndex, column, columnApi, api, dataSourceApi }, event) => void`)

> Callback function called when a cell has been clicked.

The first argument of the function is an object that contains the following properties:

- `rowIndex: number` - the index of the row that was clicked.
- `colIndex: number` - the index of the column that was clicked. This index is the index in the array of visible columns.
- `column: InfiniteTableComputedColumn<DATA_TYPE>` - the column that has been clicked
- `columnApi: InfiniteTableColumnApi<DATA_TYPE>` - the [column API](https://infinite-table.com/docs/reference/column-api/index.md)
- `api: InfiniteTableApi<DATA_TYPE>` - a reference to the [API](https://infinite-table.com/docs/reference/api/index.md)
- `dataSourceApi: DataSourceApi<DATA_TYPE>` - a reference to the [Data Source API](https://infinite-table.com/angular/docs/reference/datasource-api/index.md). Can be used to get the current data.

The second argument is the original browser click event.

### onColumnOrderChange (`(columnOrder: string[])=>void`)

> Called as a result of user changing the column order

### onColumnSizingChange (`(columnSizing)=>void`)

> Called as a result of user doing a column resize.

Use this callback to get updated information after a column resize is performed.

This works well in combination with the controlled [`[(columnSizing)]`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#columnSizing) prop (though you don't have to use controlled [`[(columnSizing)]`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#columnSizing) in order to use this callback). For more info on resizing columns, see [Column Sizing](https://infinite-table.com/angular/docs/learn/columns/fixed-and-flexible-size.md).

See related [`(viewportReservedWidthChange)`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#onViewportReservedWidthChange)

**Example: Controlled column sizing example with onColumnSizingChange**

```ts
import { Component, signal } from '@angular/core';
import { JsonPipe } from '@angular/common';

import { DataSource, InfiniteTable } from '@infinite-table/infinite-angular';
import type {
  InfiniteTableColumnGroup,
  InfiniteTablePropColumnSizing,
  InfiniteTablePropColumns,
} from '@infinite-table/infinite-angular';

type Developer = {
  id: number;
  firstName: string;
  lastName: string;
  country: string;
  city: string;
  currency: string;
  preferredLanguage: string;
  stack: string;
  canDesign: 'yes' | 'no';
  hobby: string;
  salary: number;
  age: number;
};

const dataSource = () => {
  return fetch(process.env.NEXT_PUBLIC_BASE_URL + '/developers1k')
    .then((r) => r.json())
    .then((data: Developer[]) => data);
};

const columns: InfiniteTablePropColumns<Developer> = {
  currency: {
    field: 'currency',
    columnGroup: 'finance',
  },
  salary: {
    field: 'salary',
    columnGroup: 'finance',
  },
  country: {
    field: 'country',
    columnGroup: 'regionalInfo',
    maxWidth: 400,
  },
  preferredLanguage: {
    field: 'preferredLanguage',
    columnGroup: 'regionalInfo',
  },
  id: { field: 'id' },
  firstName: {
    field: 'firstName',
  },
  stack: {
    field: 'stack',
  },
};

const columnGroups: Record<string, InfiniteTableColumnGroup> = {
  regionalInfo: {
    header: 'Regional Info',
  },
  finance: {
    header: 'Finance',
    columnGroup: 'regionalInfo',
  },
};

@Component({
  selector: 'demo-root',
  imports: [DataSource, InfiniteTable, JsonPipe],
  template: `
    <p style="color: var(--infinite-cell-color)">
      Current column sizing:
      <code>
        <pre>{{ columnSizing() | json }}</pre>
      </code>
    </p>
    <infinite-data-source primaryKey="id" [data]="dataSource">
      <infinite-table
        debugId="onColumnSizingChange-example"
        [(columnSizing)]="columnSizing"
        [columnGroups]="columnGroups"
        [columns]="columns"
        [columnDefaultWidth]="100"
      />
    </infinite-data-source>
  `,
})
export default class App {
  protected readonly dataSource = dataSource;
  protected readonly columns = columns;
  protected readonly columnGroups = columnGroups;

  
  protected readonly columnSizing = signal<InfiniteTablePropColumnSizing>({
    salary: {
      maxWidth: 130,
      width: 80,
    },
    currency: {
      maxWidth: 130,
      width: 80,
    },
  });
}
```

### onEditAccepted (`({value, initialValue, column, rowInfo, ...}) => void`)

> Callback prop called when an edit is accepted

In order to decide whether an edit should be accepted or not, you can use the global [`shouldAcceptEdit`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#shouldAcceptEdit) prop or the column-level [column.shouldAcceptEdit](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#columns.shouldAcceptEdit) alternative.

When neither the global [`shouldAcceptEdit`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#shouldAcceptEdit) nor the column-level [column.shouldAcceptEdit](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#columns.shouldAcceptEdit) are defined, all edits are accepted by default.

This callback is called with a single object that has the following properties:

- `value` - the value that was accepted for the edit operation.
- `initialValue` - the initial value of the cell (the value before editing started)
- `rowInfo` - of type [`InfiniteTableRowInfo`](https://infinite-table.com/docs/reference/type-definitions/index.md#InfiniteTableRowInfo) - the row info object that underlies the row
- `api` - a reference to the [InfiniteTable API](https://infinite-table.com/docs/reference/api/index.md)
- `dataSouceApi` - a reference to the [DataSource API](https://infinite-table.com/angular/docs/reference/datasource-api/index.md)
- `column` - the column on which the edit was performed
- `columnApi` - a reference to the [column API](https://infinite-table.com/docs/reference/column-api/index.md)

See related [`(editRejected)`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#onEditRejected) callback prop.

### onEditPersistSuccess (`({value, initialValue, column, rowInfo, ...})=>void`)

> Callback prop called when an edit is persisted successfully

Has the same signature as [`(editAccepted)`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#onEditAccepted)

### onEditRejected (`({ value, initialValue, column, rowInfo, ... }) => void`)

> Callback prop called when an edit is rejected

In order to decide whether an edit should be accepted or rejected, you can use the global [`shouldAcceptEdit`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#shouldAcceptEdit) prop or the column-level [column.shouldAcceptEdit](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#columns.shouldAcceptEdit) alternative.

When neither the global [`shouldAcceptEdit`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#shouldAcceptEdit) nor the column-level [column.shouldAcceptEdit](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#columns.shouldAcceptEdit) are defined, all edits are accepted by default.

This callback prop has almost the same signature as the [`(editAccepted)`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#onEditAccepted) callback prop. The only difference is that the argument passed to the function also contains an `error` property, with a reference to the error that caused the edit to be rejected.

### onFocusWithin (`(event)=> void`)

> Function that is called when the table receives focus within the component.

For the corresponding blur event, see [`(blurWithin)`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#onBlurWithin)

**Example: Focus an input inside the table to see the callback fired**

```ts
import { Component, TemplateRef, viewChild } from '@angular/core';

import { DataSource, InfiniteTable } from '@infinite-table/infinite-angular';
import type { InfiniteTableColumn } from '@infinite-table/infinite-angular';

import { data } from './data';
import type { Person } from './data';

const focusedWithinStyle = {
  outline: '3px solid tomato',
};

@Component({
  selector: 'demo-root',
  imports: [DataSource, InfiniteTable],
  template: `
    <infinite-data-source [data]="data" primaryKey="Id">
      <infinite-table
        debugId="onFocusWithin-example"
        (focusWithin)="onFocusWithin()"
        [focusedWithinStyle]="focusedWithinStyle"
        [columns]="columns"
      />
    </infinite-data-source>

    <ng-template #inputCell let-value="value">
      <input type="text" [value]="value" />
    </ng-template>
  `,
})
export default class App {
  protected readonly data = data;
  protected readonly focusedWithinStyle = focusedWithinStyle;

  private readonly inputCell =
    viewChild.required<TemplateRef<unknown>>('inputCell');

  protected readonly columns: Record<string, InfiniteTableColumn<Person>> = {
    id: {
      field: 'Id',
      type: 'number',
      defaultSortable: true,
      defaultWidth: 80,
    },
    firstName: {
      field: 'FirstName',
      render: () => this.inputCell(),
    },
    age: { field: 'Age', type: 'number' },
  };

  protected onFocusWithin() {
    console.log('onFocusWithin');
  }
}
```

### onKeyDown (`({ api, dataSourceApi }, event) => void | InfiniteTablePropOnKeyDownResult`)

> Callback function called when the `keydown` event occurs on the table.

The first argument of the function is an object that contains the following properties:

- `api: InfiniteTableApi<DATA_TYPE>` - a reference to the [API](https://infinite-table.com/docs/reference/api/index.md)
- `dataSourceApi: DataSourceApi<DATA_TYPE>` - a reference to the [Data Source API](https://infinite-table.com/angular/docs/reference/datasource-api/index.md). Can be used to get the current data.

The second argument is the original browser `keydown` event.

If you want to prevent some default behaviours, you can return an object with the following properties:

- `preventEdit: boolean` - if true, the cell editor will not be shown when hitting the `Enter` key in an editable cell.
- `preventEditStop: boolean` - if true, hitting the `Escape` key will not stop the edit.
- `preventSelection: boolean` - if true, the ` ` and `Cmd+a` keys will not select cells/rows
- `preventNavigation: boolean` - if true, keyboard navigation will be prevented when using `arrow` keys, `page up/down`, `home/end`, `enter`.

For keyboard shortcuts, see [`keyboardShortcuts`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#keyboardShortcuts).

### onReady (`({api, dataSourceApi}) => void}`)

> Callback prop that is being called when the table is ready.

This is called only once with an object that has an `api` property, which is an instance of [`InfiniteTableApi<DATA_TYPE>`](https://infinite-table.com/docs/reference/api/index.md) and a `dataSourceApi` property, which is an instance of [`DataSourceApi<DATA_TYPE>`](https://infinite-table.com/angular/docs/reference/datasource-api/index.md).

The `ready` state for the table means it has been layout out and has measured its available size for laying out the columns.

It will never be called again after the component is ready.

### onRenderRangeChange (`(range)=>void`)
> Called whenever the render range changes, that is, additional rows or columns come into view.

The first (and only) argument is an object with `{start, end}` where both `start` and `end` are arrays of `[rowIndex, colIndex]` pairs.

 So if you want to get the start and end indexes, you can do

 ```ts
const [startRow, startCol] = renderRange.start;
const [endRow, endCol] = renderRange.end;
```

This callback is not debounced or throttled, so it can be called multiple times in a short period of time, especially while scrolling. Make sure your function is fast, or attach a debounced function, in order to avoid performance issues.

```ts
import {
  debounce,
  InfiniteTable,
  DataSource,
} from '@infinite-table/infinite-angular';

@Component({
  selector: 'app-root',
  imports: [DataSource, InfiniteTable],
  template: `
    <infinite-data-source primaryKey="id" [data]="data">
      <infinite-table
        [columns]="columns"
        (renderRangeChange)="onRenderRangeChange($event)"
      />
    </infinite-data-source>
  `,
})
export class App {
  protected readonly data = data;
  protected readonly columns = columns;

  protected readonly onRenderRangeChange = debounce(
    (range: TableRenderRange) => {
      console.log(range.start, range.end);
    },
    { wait: 100 },
  );
}
```

Unlike [`(scrollStop)`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#onScrollStop), this function is also called when the DataGrid is resized and also when initially rendered.

### onScrollStop (`({renderRange, viewportSize, scrollTop, scrollLeft})=>void`)

> Triggered when the user has stopped scrolling (after [`scrollStopDelay`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#scrollStopDelay) milliseconds).

This is called when the user stops scrolling for a period of time - as configured by [`scrollStopDelay`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#scrollStopDelay) (milliseconds).

The function is called with an object that has the following properties:
 - `renderRange` - the render range of the viewport. This is an object with `{start, end}` where both `start` and `end` are arrays of `[rowIndex, colIndex]` pairs.
 So if you want to get the start and end indexes, you can do
 ```ts
const [startRow, startCol] = renderRange.start;
const [endRow, endCol] = renderRange.end;
```

 - `viewportSize` - the size of the viewport - `{width, height}`
 - `scrollTop` - the scrollTop position of the viewport - `number`
 - `scrollLeft` - the scrollLeft position of the viewport - `number`

Also see [`(scrollToTop)`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#onScrollToTop), [`(scrollToBottom)`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#onScrollToBottom) and [`(renderRangeChange)`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#onRenderRangeChange).

**Example: onScrollStop is called with viewport info - scroll the grid and see the console**

```ts
import { Component } from '@angular/core';

import { DataSource, InfiniteTable } from '@infinite-table/infinite-angular';
import type {
  InfiniteTablePropColumns,
  ScrollStopInfo,
} from '@infinite-table/infinite-angular';

type Developer = {
  id: number;
  firstName: string;
  lastName: string;
  country: string;
  city: string;
  currency: string;
  preferredLanguage: string;
  stack: string;
  canDesign: 'yes' | 'no';
  hobby: string;
  salary: number;
  monthlyBonus: number;
  birthDate: Date;
  age: number;
};

const dataSource = () => {
  return fetch(process.env.NEXT_PUBLIC_BASE_URL + '/developers1k')
    .then((r) => r.json())
    .then((data: Developer[]) => data);
};
const columns: InfiniteTablePropColumns<Developer> = {
  id: { field: 'id' },
  firstName: { field: 'firstName' },
  preferredLanguage: { field: 'preferredLanguage' },
  stack: { field: 'stack' },
  country: { field: 'country' },
  age: { field: 'age', type: 'number' },
  salary: { field: 'salary', type: 'number' },
  currency: { field: 'currency', type: 'number' },
  birthDate: { field: 'birthDate', type: 'number' },
};

@Component({
  selector: 'demo-root',
  imports: [DataSource, InfiniteTable],
  template: `
    <infinite-data-source primaryKey="id" [data]="dataSource">
      <infinite-table
        debugId="onScrollStop-example"
        (scrollStop)="onScrollStop($event)"
        [columns]="columns"
        [columnDefaultWidth]="250"
      />
    </infinite-data-source>
  `,
})
export default class App {
  protected readonly dataSource = dataSource;
  protected readonly columns = columns;

  protected onScrollStop({
    renderRange,
    viewportSize,
    scrollTop,
    scrollLeft,
  }: ScrollStopInfo) {
    console.log({ renderRange, viewportSize, scrollTop, scrollLeft });
  }
}
```

### onScrollToBottom (`()=>void`)

> Triggered when the user has scrolled to the bottom of the component. Also see [`(scrollToTop)`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#onScrollToTop) and [`(scrollStop)`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#onScrollStop).

Also see [`(scrollToTop)`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#onScrollToTop) and [`(scrollStop)`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#onScrollStop).

As an example usage, we're demoing live pagination, done in combination with the [react-query](https://tanstack.com/query/latest) library.

If you want to scroll to the top of the table, you can use the [`scrollTopKey`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#scrollTopKey) prop.

**Example: Fetch new data on scroll to bottom**

```ts
import { Component, computed, signal } from '@angular/core';

import { DataSource, InfiniteTable } from '@infinite-table/infinite-angular';
import type {
  InfiniteTableColumn,
  DataSourceSingleSortInfo,
  DataSourceDataParams,
  DataSourceLivePaginationCursorFn,
} from '@infinite-table/infinite-angular';

const columns: Record<string, InfiniteTableColumn<Employee>> = {
  id: { field: 'id' },
  country: {
    field: 'country',
  },
  city: { field: 'city' },
  team: { field: 'team' },
  department: { field: 'department' },
  firstName: { field: 'firstName' },
  lastName: { field: 'lastName' },

  salary: { field: 'salary' },
  age: { field: 'age' },
};

type Employee = {
  id: number;
  companyName: string;
  companySize: string;
  firstName: string;
  lastName: string;
  country: string;
  countryCode: string;
  city: string;
  streetName: string;
  streetNo: number;
  department: string;
  team: string;
  salary: number;
  age: number;
  email: string;
};

type Page = {
  data: Employee[];
  hasMore: boolean;
  page: number;
  nextPageCursor: number;
  prevPageCursor: number;
};

const PAGE_SIZE = 10;

const dataSource = ({
  sortInfo,
  livePaginationCursor = 0,
}: {
  sortInfo: DataSourceSingleSortInfo<Employee> | null;
  livePaginationCursor: number;
}) => {
  return fetch(
    process.env.NEXT_PUBLIC_BASE_URL +
      `/employees10k?_limit=${PAGE_SIZE}&_sort=${sortInfo?.field}&_order=${
        sortInfo?.dir === 1 ? 'asc' : 'desc'
      }&_start=${livePaginationCursor}`,
  )
    .then(async (r) => {
      const data = await r.json();
      // we need the remote count, so we take it from headers
      const total = Number(r.headers.get('X-Total-Count')!);
      return { data, total };
    })
    .then(({ data, total }: { data: Employee[]; total: number }) => {
      const page = livePaginationCursor / PAGE_SIZE + 1;

      const prevPageCursor = Math.max(PAGE_SIZE * (page - 1), 0);
      return {
        data,
        hasMore: total > PAGE_SIZE * page,
        page,
        prevPageCursor,
        nextPageCursor: prevPageCursor + data.length,
      };
    })
    .then((response): Promise<Page> => {
      return new Promise((resolve) => {
        setTimeout(() => {
          resolve(response);
        }, 150);
      });
    });
};

const livePaginationCursorFn: DataSourceLivePaginationCursorFn<Employee> = ({
  length,
}) => {
  return length;
};

@Component({
  selector: 'demo-root',
  imports: [DataSource, InfiniteTable],
  template: `
    <!-- take the data from data(), the rows of all the pages loaded so far -->
    <infinite-data-source
      primaryKey="id"
      [data]="data()"
      [loading]="isFetchingNextPage()"
      (dataParamsChange)="onDataParamsChange($event)"
      [livePagination]="true"
      [livePaginationCursor]="livePaginationCursorFn"
    >
      <infinite-table
        debugId="live-pagination-example"
        [scrollTopKey]="scrollTopId()"
        [columnDefaultWidth]="200"
        [columns]="columns"
      />
    </infinite-data-source>
  `,
})
export default class App {
  protected readonly columns = columns;
  protected readonly livePaginationCursorFn = livePaginationCursorFn;

  private dataParams: Partial<DataSourceDataParams<Employee>> = {
    groupBy: [],
    sortInfo: undefined,
    livePaginationCursor: null,
  };

  // the pages loaded so far, with the current sorting
  private readonly pages = signal<Page[]>([]);

  // all the rows of those pages - this is the `data` of the DataSource
  protected readonly data = computed(() =>
    this.pages().flatMap((page) => page.data),
  );

  protected readonly isFetchingNextPage = signal(false);
  private isFetchingFirstPage = false;

  // when sorting changes, scroll to the top
  protected readonly scrollTopId = signal(Date.now());

  // incremented with every new query key (sorting and grouping), so a
  // response that arrives after the sorting has changed is dropped
  private queryId = 0;

  constructor() {
    this.fetchFirstPage();
  }

  protected onDataParamsChange(newDataParams: DataSourceDataParams<Employee>) {
    const previous = this.dataParams;
    this.dataParams = {
      groupBy: newDataParams.groupBy,
      sortInfo: newDataParams.sortInfo,
      livePaginationCursor: newDataParams.livePaginationCursor,
    };

    const sortInfoChanged =
      JSON.stringify(previous.sortInfo) !==
      JSON.stringify(this.dataParams.sortInfo);
    if (sortInfoChanged) {
      this.scrollTopId.set(Date.now());
    }
    // when the sorting or the grouping changes, the pages are loaded again, from the first one
    if (
      sortInfoChanged ||
      JSON.stringify(previous.groupBy) !==
        JSON.stringify(this.dataParams.groupBy)
    ) {
      this.fetchFirstPage();
    }
    if (
      previous.livePaginationCursor !== this.dataParams.livePaginationCursor
    ) {
      this.fetchNextPage();
    }
  }

  private fetchFirstPage() {
    const currentQueryId = ++this.queryId;

    this.isFetchingFirstPage = true;
    this.isFetchingNextPage.set(false);

    dataSource({
      livePaginationCursor: 0,
      sortInfo: this.dataParams
        .sortInfo as DataSourceSingleSortInfo<Employee> | null,
    }).then((page) => {
      if (currentQueryId !== this.queryId) {
        return;
      }
      this.isFetchingFirstPage = false;
      // the previous rows stay in the table until the first page with the new sorting arrives
      this.pages.set([page]);
    });
  }

  private fetchNextPage() {
    const pages = this.pages();
    const lastPage = pages[pages.length - 1];

    if (
      this.isFetchingFirstPage ||
      this.isFetchingNextPage() ||
      !lastPage?.hasMore
    ) {
      return;
    }

    const currentQueryId = this.queryId;

    this.isFetchingNextPage.set(true);

    dataSource({
      livePaginationCursor: lastPage.nextPageCursor,
      sortInfo: this.dataParams
        .sortInfo as DataSourceSingleSortInfo<Employee> | null,
    }).then((page) => {
      if (currentQueryId !== this.queryId) {
        return;
      }
      this.isFetchingNextPage.set(false);
      this.pages.update((pages) => [...pages, page]);
    });
  }
}
```

### onViewportReservedWidthChange (`(reserved: number) => void`)

> Callback to be notified of changes to [`[(viewportReservedWidth)]`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#viewportReservedWidth)

See [`[(viewportReservedWidth)]`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#viewportReservedWidth) for details. See related [`(columnSizingChange)`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#onColumnSizingChange).

When he user is performing a column resize (via drag & drop), [`(viewportReservedWidthChange)`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#onViewportReservedWidthChange) is called when the resize is finished (not the case for resizing with the **SHIFT** key pressed, when adjacent columns share the space between them since the reserved width is preserved).

Resize a column to see `viewportReservedWidth` updated and then click the button to reset it to `0px`

**Example: Using onViewportReservedWidth to respond to user column resizing**

```ts
import { Component, signal } from '@angular/core';

import { DataSource, InfiniteTable } from '@infinite-table/infinite-angular';
import type {
  InfiniteTableColumn,
  InfiniteTablePropColumnSizing,
} from '@infinite-table/infinite-angular';

type Employee = {
  id: number;
  companyName: string;
  companySize: string;
  firstName: string;
  lastName: string;
  country: string;
  countryCode: string;
  city: string;
  streetName: string;
  streetNo: string;
  department: string;
  team: string;
  salary: number;
  age: number;
  email: string;
};

const columns: Record<string, InfiniteTableColumn<Employee>> = {
  firstName: {
    field: 'firstName',
    header: 'First Name',
  },
  country: {
    field: 'country',
    header: 'Country',
  },
  city: {
    field: 'city',
    header: 'City',
  },
  salary: {
    field: 'salary',
    type: 'number',
    header: 'Salary',
  },
};

const defaultColumnSizing: InfiniteTablePropColumnSizing = {
  country: { flex: 1 },
  city: { flex: 1 },
  salary: { flex: 2 },
};

const dataSource = () => {
  return fetch(process.env.NEXT_PUBLIC_BASE_URL + '/employees100')
    .then((r) => r.json())
    .then((data: Employee[]) => data);
};

@Component({
  selector: 'demo-root',
  imports: [DataSource, InfiniteTable],
  template: `
    <div style="color: var(--infinite-cell-color)">
      <p>Current viewport reserved width: {{ viewportReservedWidth() }}px.</p>

      <button
        style="padding: 5px; margin: 5px; border: 2px solid currentColor"
        (click)="viewportReservedWidth.set(0)"
      >
        Click to reset viewportReservedWidth to 0
      </button>
    </div>
    <infinite-data-source [data]="dataSource" primaryKey="id">
      <infinite-table
        debugId="viewportReservedWidth-example"
        [columns]="columns"
        [columnDefaultWidth]="50"
        [(viewportReservedWidth)]="viewportReservedWidth"
        [defaultColumnSizing]="defaultColumnSizing"
      />
    </infinite-data-source>
  `,
})
export default class App {
  protected readonly dataSource = dataSource;
  protected readonly columns = columns;
  protected readonly defaultColumnSizing = defaultColumnSizing;

  
  protected readonly viewportReservedWidth = signal(0);
}
```

### persistEdit (`(params) => any|Error|Promise<any|Error>`)

> Custom function to persist an edit

This allows edits that have been accepted (see [`shouldAcceptEdit`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#shouldAcceptEdit)) to be persisted to a remote (or local) location.

This function is called with an object that has the following properties:

- `value` - the value that was accepted for the edit operation.
- `initialValue` - the initial value of the cell (the value that was displayed before editing started). This is the value resulting after [`columns.valueFormatter`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#columns.valueFormatter) and [`columns.renderValue`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#columns.renderValue) have been applied)
- `rawValue` - the initial value of the cell, but before any formatting and custom rendering has been applied. This is either the field value from the current data object, or the result of the column [valueGetter](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#columns.valueGetter) function.
- `data` - the current data object
- `rowInfo` - the row info object that underlies the row
- `column` - the current column on which editing is invoked
- `api` - a reference to the [InfiniteTable API](https://infinite-table.com/docs/reference/api/index.md)
- `dataSourceApi` - - a reference to the [DataSource API](https://infinite-table.com/angular/docs/reference/datasource-api/index.md)

This function can be synchronous or asynchronous. For synchronous persisting, return an `Error` if the persisting fails, or any other value if all went well.

For asynchronous persisting, you have to return a `Promise`. If the persisting fails, resolve the promise with an `Error` object or reject the promise. If the persisting succeeded, resolve the promise with any non-error value.

### pivotGrandTotalColumnPosition

> Controls the position and visibility of pivot grand-total columns

If specified as `false`, the pivot grand-total columns are not displayed.

For normal pivot total columns, see [`pivotTotalColumnPosition`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#pivotTotalColumnPosition).

Pivot total columns only display when [`[(pivotBy)]`](https://infinite-table.com/angular/docs/reference/datasource-props/index.md#pivotBy) has two or more fields (`pivotBy.length > 1`). With a single pivot field, enabling [`pivotTotalColumnPosition`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#pivotTotalColumnPosition) has no effect — the totals would be the same as the already displayed values. The example below pivots by `stack` and `canDesign` so both pivot totals and grand totals are visible.

**Example: Pivoting with pivotGrandTotalColumnPosition=start**

```ts
import { Component } from '@angular/core';

import { DataSource, InfiniteTable } from '@infinite-table/infinite-angular';
import type {
  DataSourceGroupBy,
  DataSourcePivotBy,
  DataSourcePropAggregationReducers,
  InfiniteTableColumnAggregator,
  InfiniteTablePropColumns,
} from '@infinite-table/infinite-angular';

type Developer = {
  id: number;
  firstName: string;
  lastName: string;
  country: string;
  city: string;
  currency: string;
  preferredLanguage: string;
  stack: string;
  canDesign: 'yes' | 'no';
  hobby: string;
  salary: number;
  age: number;
};

const dataSource = () => {
  return fetch(process.env.NEXT_PUBLIC_BASE_URL + '/developers1k')
    .then((r) => r.json())
    .then((data: Developer[]) => data);
};

const columns: InfiniteTablePropColumns<Developer> = {
  id: { field: 'id', defaultWidth: 80 },
  preferredLanguage: { field: 'preferredLanguage' },
  stack: { field: 'stack' },
};

const defaultGroupBy: DataSourceGroupBy<Developer>[] = [
  {
    field: 'country',
  },
  {
    field: 'city',
  },
];

const defaultPivotBy: DataSourcePivotBy<Developer>[] = [
  {
    field: 'stack',
  },
  {
    field: 'canDesign',
    columnGroup: ({ columnGroup }) => {
      return {
        ...columnGroup,
        header:
          columnGroup.pivotGroupKey === 'yes' ? 'Designer' : 'Non-designer',
      };
    },
  },
];

const avgReducer: InfiniteTableColumnAggregator<Developer, any> = {
  initialValue: 0,

  reducer: (acc, sum) => acc + sum,
  done: (sum, arr) => Math.round(arr.length ? sum / arr.length : 0),
};

const aggregations: DataSourcePropAggregationReducers<Developer> = {
  salary: {
    ...avgReducer,
    name: 'Salary (avg)',
    field: 'salary',
  },
  age: {
    ...avgReducer,
    name: 'Age (avg)',
    field: 'age',
  },
};

@Component({
  selector: 'demo-root',
  imports: [DataSource, InfiniteTable],
  template: `
    
    <infinite-data-source
      #ds="infiniteDataSource"
      primaryKey="id"
      [defaultGroupBy]="defaultGroupBy"
      [defaultPivotBy]="defaultPivotBy"
      [aggregationReducers]="aggregations"
      [data]="dataSource"
    >
      <infinite-table
        debugId="pivot-grand-total-column-position-example"
        groupRenderStrategy="single-column"
        [columns]="columns"
        [columnDefaultWidth]="200"
        [pivotColumns]="ds.pivotColumns()"
        [pivotColumnGroups]="ds.pivotColumnGroups()"
        pivotTotalColumnPosition="end"
        pivotGrandTotalColumnPosition="start"
      />
    </infinite-data-source>
  `,
})
export default class App {
  protected readonly dataSource = dataSource;
  protected readonly columns = columns;
  protected readonly defaultGroupBy = defaultGroupBy;
  protected readonly defaultPivotBy = defaultPivotBy;
  protected readonly aggregations = aggregations;
}
```

### pivotTotalColumnPosition

> Controls the position and visibility of pivot total columns

If specified as `false`, the pivot total columns are not displayed.

For grand-total pivot columns, see [`pivotGrandTotalColumnPosition`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#pivotGrandTotalColumnPosition).

Pivot total columns only make sense when pivoting by two or more pivot fields, and thus will only display if this is the case. You can however, display grand-total columns if you have a single pivot field (or even no pivot fields - so [`[(pivotBy)]`](https://infinite-table.com/angular/docs/reference/datasource-props/index.md#pivotBy) is an empty array).

In case there are no pivot fields, but [`[(pivotBy)]`](https://infinite-table.com/angular/docs/reference/datasource-props/index.md#pivotBy) is an empty array, by default, a total column will be displayed for each aggregation (unless you specify [`pivotTotalColumnPosition`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#pivotTotalColumnPosition) as `false`).

**Example: Pivoting with pivotTotalColumnPosition=start**

```ts
import { Component } from '@angular/core';

import { DataSource, InfiniteTable } from '@infinite-table/infinite-angular';
import type {
  DataSourceGroupBy,
  DataSourcePivotBy,
  DataSourcePropAggregationReducers,
  InfiniteTableColumnAggregator,
  InfiniteTablePropColumns,
} from '@infinite-table/infinite-angular';

type Developer = {
  id: number;
  firstName: string;
  lastName: string;
  country: string;
  city: string;
  currency: string;
  preferredLanguage: string;
  stack: string;
  canDesign: 'yes' | 'no';
  hobby: string;
  salary: number;
  age: number;
};

const dataSource = () => {
  return fetch(process.env.NEXT_PUBLIC_BASE_URL + '/developers1k')
    .then((r) => r.json())
    .then((data: Developer[]) => data);
};

const columns: InfiniteTablePropColumns<Developer> = {
  id: { field: 'id', defaultWidth: 80 },
  preferredLanguage: { field: 'preferredLanguage' },
  stack: { field: 'stack' },
};

const defaultGroupBy: DataSourceGroupBy<Developer>[] = [
  {
    field: 'country',
  },
  {
    field: 'city',
  },
];

const defaultPivotBy: DataSourcePivotBy<Developer>[] = [
  {
    field: 'stack',
  },
  {
    field: 'canDesign',
    columnGroup: ({ columnGroup }) => {
      return {
        ...columnGroup,
        header:
          columnGroup.pivotGroupKey === 'yes' ? 'Designer' : 'Non-designer',
      };
    },
  },
];

const avgReducer: InfiniteTableColumnAggregator<Developer, any> = {
  initialValue: 0,

  reducer: (acc, sum) => acc + sum,
  done: (sum, arr) => Math.round(arr.length ? sum / arr.length : 0),
};

const aggregations: DataSourcePropAggregationReducers<Developer> = {
  salary: {
    ...avgReducer,
    name: 'Salary (avg)',
    field: 'salary',
  },
  age: {
    ...avgReducer,
    name: 'Age (avg)',
    field: 'age',
  },
};

@Component({
  selector: 'demo-root',
  imports: [DataSource, InfiniteTable],
  template: `
    
    <infinite-data-source
      #ds="infiniteDataSource"
      primaryKey="id"
      [defaultGroupBy]="defaultGroupBy"
      [defaultPivotBy]="defaultPivotBy"
      [aggregationReducers]="aggregations"
      [data]="dataSource"
    >
      <infinite-table
        debugId="pivot-total-column-position-example"
        groupRenderStrategy="single-column"
        [columns]="columns"
        [columnDefaultWidth]="200"
        [pivotColumns]="ds.pivotColumns()"
        [pivotColumnGroups]="ds.pivotColumnGroups()"
        pivotTotalColumnPosition="start"
      />
    </infinite-data-source>
  `,
})
export default class App {
  protected readonly dataSource = dataSource;
  protected readonly columns = columns;
  protected readonly defaultGroupBy = defaultGroupBy;
  protected readonly defaultPivotBy = defaultPivotBy;
  protected readonly aggregations = aggregations;
}
```

### repaintCellsKey (`string|number|object|(params: InfiniteTablePropRepaintCellsKeyFnParams) => any`)

> Forces cells to re-render when their own row did not change, but something they render depends on did.

For performance, a body cell only re-renders when the [`InfiniteTableRowInfo`](https://infinite-table.com/docs/reference/type-definitions/index.md#InfiniteTableRowInfo) of its own row changes (or when one of its props, like the column, changes). This means a cell whose content depends on **other rows** - a running total, the average of its group, a value looked up in another row - is not re-rendered when one of those other rows is updated, and shows a stale value.

Use `repaintCellsKey` to tell the table when such cells need to repaint:

- when a **`string`, `number` or `object`** - all cells re-render whenever the key changes (compare with [`refetchKey`](https://infinite-table.com/angular/docs/reference/datasource-props/index.md#refetchKey) on the `DataSource`, which reloads the data). Use it as a counter, or pass an object whose identity changes when your derived data changes.
- when a **function** - it is called for each cell after every data change and the cell re-renders when the returned key is different (via `Object.is`) from the key returned on the previous data change. Return primitives or stable references - returning a new object on every call repaints the cell on every data change. The function is called with an object with the following properties:
  - `rowInfo` - the current row - see [`InfiniteTableRowInfo`](https://infinite-table.com/docs/reference/type-definitions/index.md#InfiniteTableRowInfo)
  - `column` - the current column - see [`InfiniteTableComputedColumn`](https://infinite-table.com/docs/reference/type-definitions/index.md#InfiniteTableComputedColumn)
  - `dataSourceState` - the [`DataSourceState`](https://infinite-table.com/docs/reference/type-definitions/index.md#DataSourceState) that produced the current data - `originalDataArray` (all rows, unfiltered), `dataArray` (the rows as displayed) and `originalDataArrayChangedInfo` (a new object on every data mutation, with the `mutations` keyed by primary key) are the useful properties here
  - `previousDataSourceState` - the [`DataSourceState`](https://infinite-table.com/docs/reference/type-definitions/index.md#DataSourceState) before the last data change (`undefined` before the first data change)

A good key for a function is the derived value itself: return the group average the cell displays, and the cell repaints exactly when that average changes.

This prop applies to all columns. A column can specify its own [`columns.repaintCellsKey`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#columns.repaintCellsKey), which takes precedence over this prop for the cells of that column.

The function form of `repaintCellsKey` runs for every rendered cell of every affected column on each data change - keep it cheap. Cheap keys are values already available on the `DataSource` state (eg `dataSourceState.originalDataArrayChangedInfo`, a new object on every data mutation) or a small computation over `dataSourceState.originalDataArray`.

Both "Country avg" columns render the average salary of the row's country. Edit a salary cell (or click "Update salary of first row"): the column without `repaintCellsKey` shows the stale average on the other rows of that country, while the column with `repaintCellsKey` is updated.

"Repaint all cells" bumps the table-level `repaintCellsKey` and refreshes the stale column as well.

Note: the example re-scans all the rows to compute the average for each cell - that's not a performant way to do aggregations and is only done here to keep the demo short.

**Example: Repainting cells that depend on other rows**

```ts
import { Component, signal } from '@angular/core';

import { DataSource, InfiniteTable } from '@infinite-table/infinite-angular';
import type {
  DataSourceApi,
  DataSourceSingleSortInfo,
  InfiniteTablePropColumns,
} from '@infinite-table/infinite-angular';

type Developer = {
  id: number;
  firstName: string;
  lastName: string;
  country: string;
  city: string;
  currency: string;
  preferredLanguage: string;
  stack: string;
  canDesign: 'yes' | 'no';
  hobby: string;
  salary: number;
  age: number;
};

const dataSource = () => {
  return fetch(process.env.NEXT_PUBLIC_BASE_URL + '/developers100')
    .then((r) => r.json())
    .then((data: Developer[]) => data);
};

// NOTE: scanning all the rows for every cell, on every data change, is NOT
// a performant way to compute averages or other aggregations - it's done
// here only to keep the demo short. In a real app, compute the aggregations
// once per data change (eg. a memoized map keyed by country) and have both
// `repaintCellsKey` and `render` read from it.
function averageSalaryFor(rows: Developer[], country: string) {
  const countryRows = rows.filter((row) => row.country === country);
  const sum = countryRows.reduce((total, row) => total + row.salary, 0);
  return countryRows.length ? Math.round(sum / countryRows.length) : 0;
}

const columns: InfiniteTablePropColumns<Developer> = {
  firstName: { field: 'firstName' },
  country: { field: 'country' },
  salary: {
    field: 'salary',
    type: 'number',
    defaultEditable: true,
    header: 'Salary (editable)',
  },
  stale: {
    header: 'Country avg - no repaintCellsKey',
    type: 'number',
    defaultWidth: 260,
    // depends on OTHER rows - goes stale when another row
    // in the same country is edited
    render: ({ rowInfo, dataSourceApi }) => {
      if (rowInfo.isGroupRow) {
        return null;
      }
      return averageSalaryFor(
        dataSourceApi.getOriginalDataArray(),
        rowInfo.data.country,
      );
    },
  },
  fresh: {
    header: 'Country avg - with repaintCellsKey',
    type: 'number',
    defaultWidth: 260,
    // the derived value is the key, so cells re-render
    // only when their country average actually changes
    repaintCellsKey: ({ rowInfo, dataSourceState }) => {
      if (rowInfo.isGroupRow) {
        return null;
      }
      return averageSalaryFor(
        dataSourceState.originalDataArray,
        rowInfo.data.country,
      );
    },
    render: ({ rowInfo, dataSourceApi }) => {
      if (rowInfo.isGroupRow) {
        return null;
      }
      return averageSalaryFor(
        dataSourceApi.getOriginalDataArray(),
        rowInfo.data.country,
      );
    },
  },
};

const defaultSortInfo: DataSourceSingleSortInfo<Developer> = {
  field: 'country',
  dir: 1,
};

const domProps = { style: { height: 400 } };

@Component({
  selector: 'demo-root',
  imports: [DataSource, InfiniteTable],
  template: `
    <div style="display: flex; gap: 10px; padding: 10px">
      <button (click)="updateFirstRowSalary()">
        Update salary of first row
      </button>
      <button (click)="repaintCellsKey.set(repaintCellsKey() + 1)">
        Repaint all cells
      </button>
    </div>
    <infinite-data-source
      [data]="dataSource"
      primaryKey="id"
      (ready)="dataSourceApi = $event"
      [defaultSortInfo]="defaultSortInfo"
    >
      <infinite-table
        [columns]="columns"
        [columnDefaultWidth]="150"
        [repaintCellsKey]="repaintCellsKey()"
        [domProps]="domProps"
      />
    </infinite-data-source>
  `,
})
export default class App {
  protected readonly dataSource = dataSource;
  protected readonly columns = columns;
  protected readonly defaultSortInfo = defaultSortInfo;
  protected readonly domProps = domProps;

  protected dataSourceApi: DataSourceApi<Developer> | null = null;
  protected readonly repaintCellsKey = signal(0);

  protected updateFirstRowSalary() {
    const firstRow = this.dataSourceApi?.getDataByIndex(0);
    if (firstRow) {
      this.dataSourceApi?.updateData({
        id: firstRow.id,
        salary: Math.round(Math.random() * 200_000),
      });
    }
  }
}
```

### resizableColumns (`boolean`)

> Controls if by default all columns are resizable or not.

This property controls the behavior for all columns that don't have [`columns.resizable`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#columns.resizable) explicitly specified.

For resizable columns, hover the mouse between column headers to grab & drag the resize handle.

Hold SHIFT when grabbing in order to **share space on resize**.

**Example: Resizable columns example**

```ts
import { Component, signal } from '@angular/core';

import { DataSource, InfiniteTable } from '@infinite-table/infinite-angular';
import type { InfiniteTableColumn } from '@infinite-table/infinite-angular';

export const columns: Record<string, InfiniteTableColumn<Employee>> = {
  firstName: {
    field: 'firstName',
    header: 'First Name',
  },
  country: {
    field: 'country',
    header: 'Country',
  },
  city: {
    field: 'city',
    header: 'City',
  },
  salary: {
    field: 'salary',
    type: 'number',
    header: 'Salary',
  },
};

@Component({
  selector: 'demo-root',
  imports: [DataSource, InfiniteTable],
  template: `
    <div style="color: var(--infinite-cell-color)">
      <button
        style="padding: 10px; border: 2px solid currentColor"
        (click)="resizableColumns.set(!resizableColumns())"
      >
        Click to toggle
      </button>

      <p style="padding: 10px">
        Columns are currently
        {{ resizableColumns() ? 'resizable' : 'NOT RESIZABLE' }}.
      </p>
    </div>
    <infinite-data-source [data]="dataSource" primaryKey="id">
      <infinite-table
        debugId="resizableColumns-example"
        [resizableColumns]="resizableColumns()"
        [columns]="columns"
        [columnDefaultWidth]="100"
        [columnMinWidth]="30"
      />
    </infinite-data-source>
  `,
})
export default class App {
  protected readonly dataSource = dataSource;
  protected readonly columns = columns;

  protected readonly resizableColumns = signal(true);
}

const dataSource = () => {
  return fetch(process.env.NEXT_PUBLIC_BASE_URL + '/employees100')
    .then((r) => r.json())
    .then((data: Employee[]) => data);
};

export type Employee = {
  id: number;
  companyName: string;
  companySize: string;
  firstName: string;
  lastName: string;
  country: string;
  countryCode: string;
  city: string;
  streetName: string;
  streetNo: string;
  department: string;
  team: string;
  salary: number;
  age: number;
  email: string;
};
```

### rowHeight (`number|string`)

> Specifies the height for rows. If a string is passed, it should be the name of a CSS variable, eg `--row-height`

**Example: rowHeight as number**

```ts
import { Component } from '@angular/core';

import { DataSource, InfiniteTable } from '@infinite-table/infinite-angular';
import type { InfiniteTableColumn } from '@infinite-table/infinite-angular';

import { data } from './data';
import type { Person } from './data';

const columns: Record<string, InfiniteTableColumn<Person>> = {
  id: {
    // specifies which field from the data source
    // should be rendered in this column
    field: 'Id',
    type: 'number',
    defaultSortable: true,
    defaultWidth: 80,
  },
  firstName: {
    field: 'FirstName',
  },
  age: { field: 'Age', type: 'number' },
};

@Component({
  selector: 'demo-root',
  imports: [DataSource, InfiniteTable],
  template: `
    <infinite-data-source [data]="data" primaryKey="Id">
      <infinite-table
        debugId="rowHeight-number-example"
        [rowHeight]="50"
        [columns]="columns"
      />
    </infinite-data-source>
  `,
})
export default class App {
  protected readonly data = data;
  protected readonly columns = columns;
}
```

**Example: rowHeight from CSS variable name**

```ts
import { Component } from '@angular/core';

import { DataSource, InfiniteTable } from '@infinite-table/infinite-angular';
import type { InfiniteTableColumn } from '@infinite-table/infinite-angular';

import { data } from './data';
import type { Person } from './data';

const columns: Record<string, InfiniteTableColumn<Person>> = {
  id: {
    // specifies which field from the data source
    // should be rendered in this column
    field: 'Id',
    type: 'number',
    defaultSortable: true,
    defaultWidth: 80,
  },
  firstName: {
    field: 'FirstName',
  },
  age: { field: 'Age', type: 'number' },
};

@Component({
  selector: 'demo-root',
  imports: [DataSource, InfiniteTable],
  template: `
    <div style="position: relative; flex: 1; display: flex; --row-height: 70px">
      <infinite-data-source [data]="data" primaryKey="Id">
        <infinite-table
          debugId="rowHeight-cssvar-example"
          rowHeight="--row-height"
          [columns]="columns"
        />
      </infinite-data-source>
    </div>
  `,
})
export default class App {
  protected readonly data = data;
  protected readonly columns = columns;
}
```

### rowHoverClassName (`string?`)

> Specifies the className to be applied to a row, when it is hovered.

This property is static and cannot be a function, as applying the hover style does not trigger a re-render.
Combined with the related [`rowClassName`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#rowClassName) you will be able to achieve any dynamic use-case your app may need.

In the example below, we applied `bg-orange-800!` (notice the Tailwind important `!` modifier) - because the default Infinite row styles target the `background` of the rows, and not the `background-color` as Tailwind CSS `bg-*` classes. Hence the important CSS modifier.

**Example: Changing the row hover background**

```ts
import { Component } from '@angular/core';

import { DataSource, InfiniteTable } from '@infinite-table/infinite-angular';
import type { InfiniteTablePropColumns } from '@infinite-table/infinite-angular';

type Developer = {
  id: number;
  firstName: string;
  lastName: string;
  country: string;
  city: string;
  currency: string;
  preferredLanguage: string;
  stack: string;
  canDesign: 'yes' | 'no';
  hobby: string;
  salary: number;
  age: number;
};

const columns: InfiniteTablePropColumns<Developer> = {
  id: { field: 'id', defaultWidth: 80 },
  firstName: { field: 'firstName' },
  preferredLanguage: { field: 'preferredLanguage' },
  salary: { field: 'salary', type: 'number' },
};

const dataSource = () => {
  return fetch(process.env.NEXT_PUBLIC_BASE_URL + '/developers100')
    .then((r) => r.json())
    .then((data: Developer[]) => data);
};

@Component({
  selector: 'demo-root',
  imports: [DataSource, InfiniteTable],
  template: `
    <infinite-data-source primaryKey="id" [data]="dataSource">
      <infinite-table
        debugId="row-hover-class-name-example"
        [columns]="columns"
        [columnDefaultWidth]="200"
        rowHoverClassName="bg-orange-800!"
      />
    </infinite-data-source>
  `,
})
export default class App {
  protected readonly dataSource = dataSource;
  protected readonly columns = columns;
}
```

### rowClassName (`string|(params:InfiniteTableStylingFnParams) => string`)

> Specifies the className to be applied to all rows or conditionally to certain rows.

The `rowClassName` prop can be either a string or a function that returns a string.

When used as a function, it's called with a param of type [`InfiniteTableStylingFnParams`](https://infinite-table.com/docs/reference/type-definitions/index.md#InfiniteTableStylingFnParams), just like the [`rowStyle`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#rowStyle) function.

### rowStyle (`CSSProperties|(params:InfiniteTableStylingFnParams) => CSSProperties`)

> Specifies the style object to be applied to all rows or conditionally to certain rows.

The `rowStyle` prop can be either an object (typed as `React.CSSProperties`) or a function that is called with a param of type [`InfiniteTableStylingFnParams`](https://infinite-table.com/docs/reference/type-definitions/index.md#InfiniteTableStylingFnParams)

### `rowStyle` as a function

When `rowStyle` is a function, it's called with a param of type [`InfiniteTableStylingFnParams`](https://infinite-table.com/docs/reference/type-definitions/index.md#InfiniteTableStylingFnParams)

When Infinite Table calls `rowStyle`, the `data` property can be null - this is the case for grouped rows.

The `rowInfo` object contains the following properties (see [type definition here](https://infinite-table.com/docs/reference/type-definitions/index.md#InfiniteTableRowInfo)):

- `id` - the id of the current row
- `data` - the data object
- `indexInAll` - the index in the whole dataset
- `indexInGroup` - the index of the row in the current group
- `groupBy` - the fields used to group the `DataSource`
- `isGroupRow` - whether the row is a group row
- `collapsed` - for a group row, whether the group row is collapsed

See [Using RowInfo](https://infinite-table.com/angular/docs/learn/rows/using-row-info.md) for more details.

You can either return a valid style object, or undefined.

```tsx
const rowStyle: InfiniteTablePropRowStyle<Employee> = ({
  data,
  rowInfo,
}: {
  data: Partial<Employee> | null;
  rowInfo: InfiniteTableRowInfo<Employee>;
}) => {
  const salary = data?.salary ?? 0;

  if (salary > 150_000) {
    return { background: 'tomato' };
  }
  if (rowInfo.indexInAll % 10 === 0) {
    return { background: 'lightblue', color: 'black' };
  }
  return undefined;
};
```

**Example: rowStyle example usage**

```ts
import { Component } from '@angular/core';

import { DataSource, InfiniteTable } from '@infinite-table/infinite-angular';
import type {
  InfiniteTablePropRowStyle,
  InfiniteTableRowInfo,
} from '@infinite-table/infinite-angular';

import { columns } from './rowStyle-example-columns.angular';
import type { Employee } from './rowStyle-example-columns.angular';

const rowStyle: InfiniteTablePropRowStyle<Employee> = (param: {
  rowInfo: InfiniteTableRowInfo<Employee>;
}) => {
  const { rowInfo } = param;
  if (rowInfo.isGroupRow) {
    return;
  }
  const { data } = rowInfo;
  const salary = data ? data.salary : 0;

  if (salary > 150_000) {
    return { background: 'tomato' };
  }

  if (rowInfo.indexInAll % 10 === 0) {
    return { background: 'lightblue', color: 'black' };
  }
  return undefined;
};

const dataSource = () => {
  return fetch(process.env.NEXT_PUBLIC_BASE_URL + '/employees100')
    .then((r) => r.json())
    .then((data: Employee[]) => data);
};

@Component({
  selector: 'demo-root',
  imports: [DataSource, InfiniteTable],
  template: `
    <infinite-data-source [data]="dataSource" primaryKey="id">
      <infinite-table
        debugId="rowStyle-example"
        [columns]="columns"
        [rowStyle]="rowStyle"
      />
    </infinite-data-source>
  `,
})
export default class App {
  protected readonly dataSource = dataSource;
  protected readonly columns = columns;
  protected readonly rowStyle = rowStyle;
}
```

### viewportReservedWidth (`number`)

> Specifies the width of the space to be kept as blank - useful when there are flex columns. This number can even be negative.

The flexbox algorithm also uses `viewportReservedWidth` to determine the width of the viewport to use for sizing columns - you can use `viewportReservedWidth=100` to always have a `100px` reserved area that won't be used for flexing columns.

Or you can use a negative value, eg `-200` so the flexbox algorithm will use another `200px` (in addition to the available viewport area) for sizing flexible columns - this will result in a horizontal scrollbar being visible.

For reacting to column resizing, you need to listen to [`(viewportReservedWidthChange)`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#onViewportReservedWidthChange)

Resize a column to see `viewportReservedWidth` updated and then click the button to reset it to `0px`

**Example: Using viewportReservedWidth to reserve whitespace when you have flexible columns**

```ts
import { Component, signal } from '@angular/core';

import { DataSource, InfiniteTable } from '@infinite-table/infinite-angular';
import type {
  InfiniteTableColumn,
  InfiniteTablePropColumnSizing,
} from '@infinite-table/infinite-angular';

type Employee = {
  id: number;
  companyName: string;
  companySize: string;
  firstName: string;
  lastName: string;
  country: string;
  countryCode: string;
  city: string;
  streetName: string;
  streetNo: string;
  department: string;
  team: string;
  salary: number;
  age: number;
  email: string;
};

const columns: Record<string, InfiniteTableColumn<Employee>> = {
  firstName: {
    field: 'firstName',
    header: 'First Name',
  },
  country: {
    field: 'country',
    header: 'Country',
  },
  city: {
    field: 'city',
    header: 'City',
  },
  salary: {
    field: 'salary',
    type: 'number',
    header: 'Salary',
  },
};

const defaultColumnSizing: InfiniteTablePropColumnSizing = {
  country: { flex: 1 },
  city: { flex: 1 },
  salary: { flex: 2 },
};

const dataSource = () => {
  return fetch(process.env.NEXT_PUBLIC_BASE_URL + '/employees100')
    .then((r) => r.json())
    .then((data: Employee[]) => data);
};

@Component({
  selector: 'demo-root',
  imports: [DataSource, InfiniteTable],
  template: `
    <div style="color: var(--infinite-cell-color)">
      <p>Current viewport reserved width: {{ viewportReservedWidth() }}px.</p>

      <button
        style="padding: 5px; margin: 5px; border: 2px solid currentColor"
        (click)="viewportReservedWidth.set(0)"
      >
        Click to reset viewportReservedWidth to 0
      </button>
    </div>
    <infinite-data-source [data]="dataSource" primaryKey="id">
      <infinite-table
        debugId="viewportReservedWidth-example"
        [columns]="columns"
        [columnDefaultWidth]="50"
        [(viewportReservedWidth)]="viewportReservedWidth"
        [defaultColumnSizing]="defaultColumnSizing"
      />
    </infinite-data-source>
  `,
})
export default class App {
  protected readonly dataSource = dataSource;
  protected readonly columns = columns;
  protected readonly defaultColumnSizing = defaultColumnSizing;

  
  protected readonly viewportReservedWidth = signal(0);
}
```

### shouldAcceptEdit (`(params) => boolean|Error|Promise<boolean|Error>`)

> Function used to validate edits for all columns.

This function is called when the user wants to finish an edit - it is used to decide whether an edit is accepted or rejected, for all columns.

<p>This overrides the column-level [column.shouldAcceptEdit](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#columns.shouldAcceptEdit) prop.</p>
<p>If you define the global [`shouldAcceptEdit`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#shouldAcceptEdit) and still want to use the column-level [column.shouldAcceptEdit](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#columns.shouldAcceptEdit), you can call the column-level function from this global one.</p>

The function is called with an object that has the following properties:

- `value` - the value that the user wants to persist via the cell editor
- `initialValue` - the initial value of the cell (the value that was displayed before editing started). This is the value resulting after [`columns.valueFormatter`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#columns.valueFormatter) and [`columns.renderValue`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#columns.renderValue) have been applied)
- `rawValue` - the initial value of the cell, but before any formatting and custom rendering has been applied. This is either the field value from the current data object, or the result of the column [valueGetter](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#columns.valueGetter) function.
- `data` - the current data object
- `rowInfo` - the row info object that underlies the row
- `column` - the current column on which editing is invoked
- `api` - a reference to the [InfiniteTable API](https://infinite-table.com/docs/reference/api/index.md)
- `dataSourceApi` - - a reference to the [DataSource API](https://infinite-table.com/angular/docs/reference/datasource-api/index.md)

Edit the `salary` column. Only valid numbers are persisted.

```ts
import { Component } from '@angular/core';

import { DataSource, InfiniteTable } from '@infinite-table/infinite-angular';
import type { InfiniteTablePropColumns } from '@infinite-table/infinite-angular';

type Developer = {
  id: number;
  firstName: string;
  currency: string;
  stack: string;
  hobby: string;
  salary: string;
};
const dataSource: Developer[] = [
  {
    id: 1,
    firstName: 'John',
    currency: 'USD',
    stack: 'frontend',
    hobby: 'gaming',
    salary: 'USD 1000',
  },
  {
    id: 2,
    firstName: 'Jane',
    currency: 'EUR',
    stack: 'backend',
    hobby: 'reading',
    salary: 'EUR 2000',
  },
  {
    id: 3,
    firstName: 'Jack',
    currency: 'GBP',
    stack: 'frontend',
    hobby: 'gaming',
    salary: 'GBP 3000',
  },
  {
    id: 4,
    firstName: 'Jill',
    currency: 'USD',
    stack: 'backend',
    hobby: 'reading',
    salary: 'USD 4000',
  },
];

const columns: InfiniteTablePropColumns<Developer> = {
  id: { field: 'id', defaultWidth: 80 },

  salary: {
    // the only editable column
    defaultEditable: true,

    defaultWidth: 320,
    field: 'salary',
    header: 'Salary - edit accepts numbers only',
    style: { color: 'tomato' },
    getValueToEdit: ({ value }) => {
      return parseInt(value.substr(4), 10);
    },
    getValueToPersist: ({ value, data }) => {
      return `${data!.currency} ${parseInt(value, 10)}`;
    },
  },

  firstName: {
    field: 'firstName',
    header: 'Name',
  },
  currency: {
    field: 'currency',
    header: 'Currency',
  },
};

const shouldAcceptEdit = ({ value }: { value: any }) => {
  return parseInt(value, 10) == value;
};

@Component({
  selector: 'demo-root',
  imports: [DataSource, InfiniteTable],
  template: `
    <infinite-data-source primaryKey="id" [data]="dataSource">
      <infinite-table
        debugId="global-should-accept-edit-example"
        [columns]="columns"
        [columnDefaultEditable]="false"
        [shouldAcceptEdit]="shouldAcceptEdit"
      />
    </infinite-data-source>
  `,
})
export default class App {
  protected readonly dataSource = dataSource;
  protected readonly columns = columns;
  protected readonly shouldAcceptEdit = shouldAcceptEdit;
}
```

### scrollTopKey (`number|string`)

> Determines scrolling the table to the top.

Use this property to declaratively tell the `InfiniteTable` component to scroll to the top. Whenever a new value is provided for this property, it will scroll to the top.

**Example: Declaratively scrolling to the top of the table**

```ts
import { Component, signal } from '@angular/core';

import { DataSource, InfiniteTable } from '@infinite-table/infinite-angular';
import type { InfiniteTablePropColumns } from '@infinite-table/infinite-angular';

type Developer = {
  id: number;
  firstName: string;
  lastName: string;
  country: string;
  city: string;
  currency: string;
  preferredLanguage: string;
  stack: string;
  canDesign: 'yes' | 'no';
  hobby: string;
  salary: number;
  age: number;
};

const dataSource = () => {
  return fetch(process.env.NEXT_PUBLIC_BASE_URL + '/developers1k')
    .then((r) => r.json())
    .then((data: Developer[]) => data);
};
const columns: InfiniteTablePropColumns<Developer> = {
  id: { field: 'id' },
  firstName: { field: 'firstName' },
  preferredLanguage: { field: 'preferredLanguage' },
  stack: { field: 'stack' },
  country: { field: 'country' },
  age: { field: 'age', type: 'number' },
  salary: { field: 'salary', type: 'number' },
  currency: { field: 'currency', type: 'number' },
};

@Component({
  selector: 'demo-root',
  imports: [DataSource, InfiniteTable],
  template: `
    <button
      style="margin: 10px; padding: 10px; border-radius: 5px; border: 2px solid magenta"
      (click)="scrollTopKey.set(scrollTopKey() + 1)"
    >
      Scroll to top
    </button>

    <infinite-data-source primaryKey="id" [data]="dataSource">
      <infinite-table
        debugId="scrollTopKey-example"
        [scrollTopKey]="scrollTopKey()"
        [columns]="columns"
        [columnDefaultWidth]="200"
      />
    </infinite-data-source>
  `,
})
export default class App {
  protected readonly dataSource = dataSource;
  protected readonly columns = columns;

  protected readonly scrollTopKey = signal(0);
}
```

### virtualizeColumns (`boolean`)

> Configures whether columns are virtualized or not

By default, columns are virtualized in order to improve performance.
