Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
472 changes: 472 additions & 0 deletions .snyk

Large diffs are not rendered by default.

36 changes: 25 additions & 11 deletions documentation/ag-grid-docs/src/content/docs-nav/nav.json
Original file line number Diff line number Diff line change
Expand Up @@ -1031,17 +1031,6 @@
"title": "Large Text Editor",
"path": "provided-cell-editors-large-text"
},
{
"type": "item",
"title": "Select Editor",
"path": "provided-cell-editors-select"
},
{
"type": "item",
"title": "Rich Select Editor",
"path": "provided-cell-editors-rich-select",
"isEnterprise": true
},
{
"type": "item",
"title": "Number Editor",
Expand All @@ -1056,6 +1045,31 @@
"type": "item",
"title": "Checkbox Editor",
"path": "provided-cell-editors-checkbox"
},
{
"type": "item",
"title": "Select Editor",
"path": "provided-cell-editors-select"
},
{
"type": "item",
"title": "Rich Select Editor",
"path": "provided-cell-editors-rich-select",
"isEnterprise": true,
"children": [
{
"type": "item",
"title": "Customisation",
"path": "provided-cell-editors-rich-select-customisation",
"isEnterprise": true
},
{
"type": "item",
"title": "Async Values",
"path": "provided-cell-editors-rich-select-async",
"isEnterprise": true
}
]
}
]
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,5 +55,3 @@ columnDefs: [
## API Reference

{% interfaceDocumentation interfaceName="ILargeTextEditorParams" names=["maxLength","rows","cols"] /%}

Continue to the next section: [Select Cell Editor](./provided-cell-editors-select/).
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
import type {
ColDef,
GridApi,
GridOptions,
IRichCellEditorParams,
RichCellEditorValuesCallbackParams,
} from 'ag-grid-community';
import type { ColDef, GridApi, GridOptions, IRichCellEditorParams } from 'ag-grid-community';
import {
ClientSideRowModelModule,
ModuleRegistry,
Expand All @@ -28,18 +22,13 @@ function getRandomNumber(min: number, max: number) {
return Math.floor(Math.random() * (max - min + 1) + min);
}

function getValueFromServer(_params: RichCellEditorValuesCallbackParams): Promise<string[]> {
return new Promise((resolve) => {
setTimeout(() => resolve(languages), 1000);
});
}

const columnDefs: ColDef[] = [
{
field: 'language',
cellEditor: 'agRichSelectCellEditor',
cellEditorParams: {
values: getValueFromServer,
// Simulates an async request to a server
values: (_params) => fetch('/api/languages').then((res) => res.json()),
} as IRichCellEditorParams,
},
];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ function getRandomNumber(min: number, max: number) {

function getValueFromServer(params: RichCellEditorValuesCallbackParams): Promise<string[]> {
const search = params.search?.toLowerCase() ?? '';
// Simulates an async request to a server
return new Promise((resolve) => {
console.log(`Grid requested \`${search}\` from server.`);
setTimeout(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ function getFilteredValuePageFromServer(
): Promise<RichCellEditorValuesPageResult<string>> {
const search = params.search.toLowerCase();

// Simulates an async request to a server
return new Promise((resolve) => {
setTimeout(() => {
const filtered = search
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ function getRandomNumber(min: number, max: number) {
function getValuePageFromServer(
params: RichCellEditorValuesPageParams
): Promise<RichCellEditorValuesPageResult<string>> {
// Simulates an async request to a server
return new Promise((resolve) => {
setTimeout(() => {
const pageValues = languages.slice(params.startRow, params.endRow);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
---
title: "Rich Select Cell Editor - Async Values"
enterprise: true
---

The Rich Select Cell Editor supports loading values asynchronously, including paged loading and server-side filtering.

## Async Values

List values can be provided asynchronously to the editor as shown below:

{% interfaceDocumentation interfaceName="IRichCellEditorParams" overrideSrc="provided-cell-editors-rich-select/rich-select.json" names=["values"] config={ "description": "" } /%}

{% gridExampleRunner title="Rich Select Async Values" name="rich-select-async-values" /%}

```js
columnDefs: [
{
field: 'language',
cellEditor: 'agRichSelectCellEditor',
cellEditorParams: {
values: (_params) => fetch('/api/languages').then((res) => res.json()),
}
}
]
```

## Paged Async Values

For large datasets, `valuesPage` avoids loading all items at once and instead loads values on demand based on user scroll and interactions. `valuesPageInitialStartRow` can be used to set the initial position. The `valuesPage` callback should return a value that conforms to the `RichCellEditorValuesPageResult` interface.

{% interfaceDocumentation interfaceName="IRichCellEditorParams" overrideSrc="provided-cell-editors-rich-select/rich-select.json" names=["valuesPage", "valuesPageInitialStartRow", "valuesPageSize", "valuesPageLoadThreshold"] config={ "description": "" } /%}

{% gridExampleRunner title="Rich Select Paged Async Values" name="rich-select-paged-async-values" /%}

```js
columnDefs: [
{
cellEditor: 'agRichSelectCellEditor',
cellEditorParams: {
valuesPage: (params) : Promise<RichCellEditorValuesPageResult<string>> {
return fetch(`/api/languages?
startRow=${params.startRow}
&endRow=${params.endRow}`)
.then((res) => res.json());
},
valuesPageInitialStartRow: (value) => getRowForSelectedValue(value),
valuesPageSize: 100,
valuesPageLoadThreshold: 10
}
}
]
```

## Async Filtering

For advanced filtering scenarios, combine async `values` callback, `allowTyping`, and `filterListAsync` to enable async filtering.

When `filterListAsync` is set to `true`, the cell editor behaves as follows:

- It calls the `values` callback with the current search term.
- It delays the search request by 300ms (this can be adjusted using `searchDebounceDelay`) to avoid excessive calls.
- A loading indicator appears while the network request is in progress.
- Once the promise resolves, the dropdown is updated with the filtered results.

{% interfaceDocumentation interfaceName="IRichCellEditorParams" overrideSrc="provided-cell-editors-rich-select/rich-select.json" names=["filterListAsync", "searchDebounceDelay", "values"] config={ "description": "" } /%}

This is shown in the example below:

{% gridExampleRunner title="Rich Select Async Filtering" name="rich-select-full-async-values" /%}

```js
columnDefs: [
{
field: 'language',
cellEditor: 'agRichSelectCellEditor',
cellEditorParams: {
allowTyping: true,
filterList: true,
filterListAsync: true,
values: (params): Promise<string[]> {
return fetch(`/api/languages?search=${encodeURIComponent(params.search)}`)
.then(res => res.json())
.then(data => data.items as string[])
}
}
]
```

## Paged Async Filtering

For very large, server-backed datasets, combine async filtering with `valuesPage` so filtered results are also loaded incrementally.
`valuesPageInitialStartRow` is only used for the initial unfiltered load; once the user types, filtered paging starts from row `0`.

In this mode each request includes:

- `search` for the current filter text.
- `startRow` and `endRow` for range-based pagination.
- `cursor` (optional) for cursor-based forward pagination APIs (`undefined` on the first request, then replayed from the previous response).

{% interfaceDocumentation interfaceName="IRichCellEditorParams" overrideSrc="provided-cell-editors-rich-select/rich-select.json" names=["filterListAsync", "valuesPage", "valuesPageInitialStartRow", "valuesPageSize", "valuesPageLoadThreshold"] config={ "description": "" } /%}

{% gridExampleRunner title="Rich Select Paged Async Filtering" name="rich-select-paged-async-filtering" /%}

```js
columnDefs: [
{
cellEditor: 'agRichSelectCellEditor',
cellEditorParams: {
allowTyping: true,
filterList: true,
filterListAsync: true,
valuesPageInitialStartRow: (value) => getRowForSelectedValue(value),
valuesPage: (params): Promise<RichCellEditorValuesPageResult<string>> {
return fetch(
`/api/languages
?search=${encodeURIComponent(params.search)}
&startRow=${params.startRow}
&endRow=${params.endRow}`
).then((res) => res.json());
},
}
}
]
```

## API

{% interfaceDocumentation interfaceName="IRichCellEditorParams" overrideSrc="provided-cell-editors-rich-select/rich-select.json" /%}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import {
import { RichSelectModule } from 'ag-grid-enterprise';

import { colors } from './colors';
import { ColourCellRenderer } from './colourCellRenderer_typescript';

ModuleRegistry.registerModules([
TextEditorModule,
Expand All @@ -22,36 +21,27 @@ const columnDefs: ColDef[] = [
{
headerName: 'Fuzzy Search',
field: 'color',
cellRenderer: ColourCellRenderer,
cellEditor: 'agRichSelectCellEditor',
cellEditorParams: {
values: colors,
cellRenderer: ColourCellRenderer,
valueListMaxHeight: 220,
} as IRichCellEditorParams,
},
{
headerName: 'Match Search',
field: 'color',
cellRenderer: ColourCellRenderer,
cellEditor: 'agRichSelectCellEditor',
cellEditorParams: {
values: colors,
cellRenderer: ColourCellRenderer,
searchType: 'match',
valueListMaxHeight: 220,
} as IRichCellEditorParams,
},
{
headerName: 'Match Any Search',
field: 'color',
cellRenderer: ColourCellRenderer,
cellEditor: 'agRichSelectCellEditor',
cellEditorParams: {
values: colors,
cellRenderer: ColourCellRenderer,
searchType: 'matchAny',
valueListMaxHeight: 220,
} as IRichCellEditorParams,
},
];
Expand Down
Loading
Loading