-
Notifications
You must be signed in to change notification settings - Fork 660
DataGrid - AI Column: Fix display of AI data during virtual scrolling #31876
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Alyar666
merged 3 commits into
DevExpress:25_2
from
Alyar666:datagrid_ai_column_fix_virtual_scrolling_25_2
Dec 1, 2025
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
33 changes: 33 additions & 0 deletions
33
e2e/testcafe-devextreme/tests/dataGrid/common/aiColumn/pages/containerWithAIIntegration.html
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| <!DOCTYPE html> | ||
| <html lang="en"> | ||
| <head> | ||
| <title>TestCafe Tests Container</title> | ||
|
|
||
| <link rel="dx-theme" data-theme="fluent.blue.light" href="../../../../../../../packages/devextreme/artifacts/css/dx.fluent.blue.light.css" data-active="false"> | ||
| <link rel="dx-theme" data-theme="fluent.blue.light.compact" href="../../../../../../../packages/devextreme/artifacts/css/dx.fluent.blue.light.compact.css" data-active="false"> | ||
| <link rel="dx-theme" data-theme="generic.light" href="../../../../../../../packages/devextreme/artifacts/css/dx.light.css" data-active="true"> | ||
| <link rel="dx-theme" data-theme="generic.light.compact" href="../../../../../../../packages/devextreme/artifacts/css/dx.light.compact.css" data-active="false"> | ||
| <link rel="dx-theme" data-theme="material.blue.light" href="../../../../../../../packages/devextreme/artifacts/css/dx.material.blue.light.css" data-active="false"> | ||
| <link rel="dx-theme" data-theme="material.blue.light.compact" href="../../../../../../../packages/devextreme/artifacts/css/dx.material.blue.light.compact.css" data-active="false"> | ||
|
|
||
| <script type="text/javascript" src="../../../../../../../packages/devextreme/artifacts/js/jquery.min.js"></script> | ||
| <script type="text/javascript" src="../../../../../../../packages/devextreme/artifacts/js/dx.all.js"></script> | ||
| <script type="text/javascript" src="../../../../../../../packages/devextreme/artifacts/js/dx.ai-integration.js"></script> | ||
| <script type="text/javascript" src="../../../../../../../packages/devextreme/artifacts/js/dx.aspnet.data.js"></script> | ||
|
|
||
| <style> | ||
| * { caret-color: transparent !important; } | ||
| .dx-scheduler .dx-scrollable-scroll { visibility: hidden !important; } | ||
| </style> | ||
| </head> | ||
| <body class="dx-surface"> | ||
| <div id="parentContainer" role="main"> | ||
| <h1 style="position: fixed; left: 0; top: 0; clip: rect(1px, 1px, 1px, 1px);">Test header</h1> | ||
|
|
||
| <div id="container"> | ||
| </div> | ||
| <div id="otherContainer"> | ||
| </div> | ||
| </div> | ||
| </body> | ||
| </html> | ||
249 changes: 249 additions & 0 deletions
249
e2e/testcafe-devextreme/tests/dataGrid/common/aiColumn/virtualScrolling.functional.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,249 @@ | ||
| import DataGrid from 'devextreme-testcafe-models/dataGrid'; | ||
| import { ClientFunction } from 'testcafe'; | ||
| import url from '../../../../helpers/getPageUrl'; | ||
| import { createWidget } from '../../../../helpers/createWidget'; | ||
|
|
||
| fixture`Ai Column.Virtual Scrolling.Functional` | ||
Alyar666 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| .page(url(__dirname, './pages/containerWithAIIntegration.html')); | ||
|
|
||
| const DATA_GRID_SELECTOR = '#container'; | ||
|
|
||
| const checkAIColumnTexts = async ( | ||
| t: TestController, | ||
| component: DataGrid, | ||
| expectedRowCount: number, | ||
| ): Promise<void> => { | ||
| const visibleRows: Record<string, any>[] = await component.apiGetVisibleRows(); | ||
|
|
||
| await t.expect(visibleRows.length).eql(expectedRowCount); | ||
|
|
||
| // eslint-disable-next-line no-restricted-syntax | ||
| for (const row of visibleRows) { | ||
| await t | ||
| .expect(component.getDataCell(row.dataIndex, 3).element.textContent) | ||
| .eql(`Response ${row.data.name}`); | ||
| } | ||
| }; | ||
|
|
||
| const resolveAIRequest = ClientFunction((): void => { | ||
| const { aiResponseData } = (window as any); | ||
| const { aiResolve } = (window as any); | ||
|
|
||
| if (aiResponseData && aiResolve) { | ||
| aiResolve(aiResponseData); | ||
|
|
||
| (window as any).aiResponseData = null; | ||
| (window as any).aiResolve = null; | ||
| } | ||
| }); | ||
|
|
||
| const deleteGlobalVariables = ClientFunction((): void => { | ||
| delete (window as any).aiResponseData; | ||
| delete (window as any).aiResolve; | ||
| }); | ||
|
|
||
| test('DataGrid should send an AI request for rendered rows after scrolling without changing the page index', async (t) => { | ||
| // arrange | ||
| const dataGrid = new DataGrid(DATA_GRID_SELECTOR); | ||
|
|
||
| // assert | ||
| await t | ||
| .expect(dataGrid.getLoadPanel().isVisible()) | ||
| .ok(); | ||
|
|
||
| // act | ||
| await resolveAIRequest(); | ||
|
|
||
| // assert | ||
| await t | ||
| .expect(dataGrid.isReady()) | ||
| .ok() | ||
| .expect(dataGrid.getLoadPanel().isVisible()) | ||
| .notOk(); | ||
| await checkAIColumnTexts(t, dataGrid, 11); | ||
|
|
||
| // act | ||
| await dataGrid.scrollTo(t, { y: 1000 }); | ||
|
|
||
| // assert | ||
| await t | ||
| .expect(dataGrid.getScrollTop()) | ||
| .eql(1000) | ||
| .expect(dataGrid.apiPageIndex()) | ||
| .eql(0) | ||
| .expect(dataGrid.getDataCell(20, 0).element.textContent) | ||
| .eql('21') | ||
| .expect(dataGrid.getLoadPanel().isVisible()) | ||
| .ok(); | ||
|
|
||
| // act | ||
| await resolveAIRequest(); | ||
|
|
||
| // assert | ||
| await t | ||
| .expect(dataGrid.isReady()) | ||
| .ok() | ||
| .expect(dataGrid.getLoadPanel().isVisible()) | ||
| .notOk(); | ||
| await checkAIColumnTexts(t, dataGrid, 12); | ||
| }) | ||
| .before(async () => createWidget('dxDataGrid', () => { | ||
| const generateData = (rowCount: number): Record<string, number | string>[] => { | ||
Raushen marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| const result: Record<string, number | string>[] = []; | ||
|
|
||
| for (let i = 0; i < rowCount; i += 1) { | ||
| result.push({ id: i + 1, name: `Name ${i + 1}`, value: (i + 1) * 10 }); | ||
| } | ||
|
|
||
| return result; | ||
| }; | ||
|
|
||
| return { | ||
| dataSource: generateData(200), | ||
| height: 500, | ||
| keyExpr: 'id', | ||
| paging: { | ||
| pageSize: 50, | ||
| }, | ||
| scrolling: { | ||
| mode: 'virtual', | ||
| }, | ||
| columns: [ | ||
| { dataField: 'id', caption: 'ID' }, | ||
| { dataField: 'name', caption: 'Name' }, | ||
| { dataField: 'value', caption: 'Value' }, | ||
| { | ||
| type: 'ai', | ||
| caption: 'AI Column', | ||
| name: 'myColumn', | ||
| ai: { | ||
| prompt: 'Initial prompt', | ||
| // eslint-disable-next-line new-cap | ||
| aiIntegration: new (window as any).DevExpress.aiIntegration({ | ||
| sendRequest(prompt) { | ||
Raushen marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| return { | ||
| promise: new Promise<string>((resolve) => { | ||
| const result: Record<string, string> = {}; | ||
|
|
||
| Object.entries(prompt.data?.data).forEach(([key, value]) => { | ||
| result[key] = `Response ${(value as any).name}`; | ||
| }); | ||
|
|
||
| (window as any).aiResponseData = JSON.stringify(result); | ||
| (window as any).aiResolve = resolve; | ||
| }), | ||
| abort: (): void => {}, | ||
| }; | ||
| }, | ||
| }), | ||
| }, | ||
| }, | ||
| ], | ||
| }; | ||
| })) | ||
| .after(async () => { | ||
| await deleteGlobalVariables(); | ||
| }); | ||
|
|
||
| test('DataGrid should send an AI request for rendered rows after scrolling with changing the page index', async (t) => { | ||
| // arrange | ||
| const dataGrid = new DataGrid(DATA_GRID_SELECTOR); | ||
|
|
||
| // assert | ||
| await t | ||
| .expect(dataGrid.getLoadPanel().isVisible()) | ||
| .ok(); | ||
|
|
||
| // act | ||
| await resolveAIRequest(); | ||
|
|
||
| // assert | ||
| await t | ||
| .expect(dataGrid.isReady()) | ||
| .ok() | ||
| .expect(dataGrid.getLoadPanel().isVisible()) | ||
| .notOk(); | ||
| await checkAIColumnTexts(t, dataGrid, 11); | ||
|
|
||
| // act | ||
| await dataGrid.scrollTo(t, { y: 1000 }); | ||
|
|
||
| // assert | ||
| await t | ||
| .expect(dataGrid.getScrollTop()) | ||
| .eql(1000) | ||
| .expect(dataGrid.apiPageIndex()) | ||
| .eql(1) | ||
| .expect(dataGrid.getDataCell(20, 0).element.textContent) | ||
| .eql('21') | ||
Alyar666 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| .expect(dataGrid.getLoadPanel().isVisible()) | ||
| .ok(); | ||
|
|
||
| // act | ||
| await resolveAIRequest(); | ||
|
|
||
| // assert | ||
| await t | ||
| .expect(dataGrid.isReady()) | ||
| .ok() | ||
| .expect(dataGrid.getLoadPanel().isVisible()) | ||
| .notOk(); | ||
| await checkAIColumnTexts(t, dataGrid, 12); | ||
| }) | ||
| .before(async () => createWidget('dxDataGrid', () => { | ||
| const generateData = (rowCount: number): Record<string, number | string>[] => { | ||
| const result: Record<string, number | string>[] = []; | ||
|
|
||
| for (let i = 0; i < rowCount; i += 1) { | ||
| result.push({ id: i + 1, name: `Name ${i + 1}`, value: (i + 1) * 10 }); | ||
| } | ||
|
|
||
| return result; | ||
| }; | ||
|
|
||
| return { | ||
| dataSource: generateData(200), | ||
| height: 500, | ||
| keyExpr: 'id', | ||
| paging: { | ||
| pageSize: 20, | ||
| }, | ||
| scrolling: { | ||
| mode: 'virtual', | ||
| }, | ||
| columns: [ | ||
| { dataField: 'id', caption: 'ID' }, | ||
| { dataField: 'name', caption: 'Name' }, | ||
| { dataField: 'value', caption: 'Value' }, | ||
| { | ||
| type: 'ai', | ||
| caption: 'AI Column', | ||
| name: 'myColumn', | ||
| ai: { | ||
| prompt: 'Initial prompt', | ||
| // eslint-disable-next-line new-cap | ||
| aiIntegration: new (window as any).DevExpress.aiIntegration({ | ||
| sendRequest(prompt) { | ||
| return { | ||
| promise: new Promise<string>((resolve) => { | ||
| const result: Record<string, string> = {}; | ||
|
|
||
| Object.entries(prompt.data?.data).forEach(([key, value]) => { | ||
| result[key] = `Response ${(value as any).name}`; | ||
| }); | ||
|
|
||
| (window as any).aiResponseData = JSON.stringify(result); | ||
| (window as any).aiResolve = resolve; | ||
| }), | ||
| abort: (): void => {}, | ||
| }; | ||
| }, | ||
| }), | ||
| }, | ||
| }, | ||
| ], | ||
| }; | ||
| })) | ||
| .after(async () => { | ||
| await deleteGlobalVariables(); | ||
| }); | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.