-
Notifications
You must be signed in to change notification settings - Fork 666
✨AI Column: Write jQuery Demo #31582
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
Raushen
merged 36 commits into
DevExpress:25_2
from
dmlvr:dg_25_2_ai_column_jquery_demo
Nov 10, 2025
Merged
Changes from 8 commits
Commits
Show all changes
36 commits
Select commit
Hold shift + click to select a range
f17819c
added DataGrid and TreeList demos for AIColumn
dmlvr 29a615d
fix lint
dmlvr 3919def
updated menuMeta.json
dmlvr 7d1fd98
Merge branch '25_2' into dg_25_2_ai_column_jquery_demo
dmlvr 0b3066a
Update apps/demos/Demos/TreeList/AIColumn/JQuery/index.js
dmlvr ded0d2e
fix lint
dmlvr 31af444
merge updates
dmlvr 04fbc0b
Merge branch '25_2' into dg_25_2_ai_column_jquery_demo
dmlvr b983caa
merge 25_2
dmlvr c2eb9b5
update demo by review comments
dmlvr 46ae17b
Load order
Raushen 0c278ee
Change theme
Raushen bce1369
Linter
Raushen f50958f
Fix path
Raushen fdd489b
Fix TreeList path
Raushen f5a8440
Fix cell style
Raushen 5f7d139
Merge branch '25_2' of github.com:DevExpress/DevExtreme into dg_25_2_…
Raushen ddc0217
Linter
Raushen 7bb7dc7
Category style
Raushen b6cf6bc
Popover appearance
Raushen 88f6d21
Remove unused properties
Raushen 5a1dc0b
TreeList DataSource
Raushen 97e3d5f
Linter
Raushen 0bfb51d
Merge branch '25_2' of github.com:DevExpress/DevExtreme into dg_25_2_…
Raushen 30b0c64
TreeList images
Raushen e78e975
Merge branch '25_2' of github.com:DevExpress/DevExtreme into dg_25_2_…
Raushen f9f8ad9
Replace popover to popup
Raushen f392200
Remove flag from prompt
Raushen aad4f02
Merge branch '25_2' of github.com:DevExpress/DevExtreme into dg_25_2_…
Raushen 05eaca7
Fix name
Raushen 621e22d
Fix styles
Raushen 1593bcc
Image accessibility
Raushen 1a9c8aa
ShowCloseButton
Raushen 6a043b2
Selector refactoring
Raushen dfd87b4
AI Column bg
Raushen c4ff9ef
typo
Raushen 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
1,897 changes: 1,897 additions & 0 deletions
1,897
apps/demos/Demos/DataGrid/AIColumn/JQuery/data.js
Large diffs are not rendered by default.
Oops, something went wrong.
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,28 @@ | ||
| <!DOCTYPE html> | ||
| <html xmlns="http://www.w3.org/1999/xhtml" lang="en"> | ||
| <head> | ||
| <title>DevExtreme Demo</title> | ||
| <meta http-equiv="X-UA-Compatible" content="IE=edge" /> | ||
| <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> | ||
| <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=5.0" /> | ||
| <link rel="stylesheet" type="text/css" href="../../../../node_modules/devextreme/dist/css/dx.light.css" /> | ||
| <script src="../../../../node_modules/jquery/dist/jquery.min.js"></script> | ||
| <script src="../../../../node_modules/devextreme-quill/dist/dx-quill.min.js"></script> | ||
| <script type="module"> | ||
| import { AzureOpenAI } from "https://esm.sh/openai@4.73.1"; | ||
|
|
||
| window.AzureOpenAI = AzureOpenAI; | ||
| </script> | ||
| <script src="../../../../node_modules/devextreme-dist/js/dx.ai-integration.js"></script> | ||
| <link rel="stylesheet" type="text/css" href="../../../../node_modules/devextreme-dist/css/dx.material.blue.light.css" /> | ||
dmlvr marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| <script src="../../../../node_modules/devextreme-dist/js/dx.all.js"></script> | ||
| <script src="data.js"></script> | ||
| <script src="index.js"></script> | ||
| <link rel="stylesheet" type="text/css" href="styles.css" /> | ||
| </head> | ||
| <body class="dx-viewport"> | ||
| <div class="demo-container"> | ||
| <div id="gridContainer"></div> | ||
| </div> | ||
| </body> | ||
| </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,162 @@ | ||
| /* eslint-disable no-undef */ | ||
dmlvr marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| $(() => { | ||
| const aiService = new AzureOpenAI({ | ||
| dangerouslyAllowBrowser: true, | ||
| deployment, | ||
| endpoint, | ||
| apiVersion, | ||
| apiKey, | ||
| }); | ||
|
|
||
| async function getAIResponse(messages, signal) { | ||
| const params = { | ||
| messages, | ||
| model: deployment, | ||
| max_tokens: 1000, | ||
| temperature: 0.7, | ||
| }; | ||
|
|
||
| const response = await aiService.chat.completions.create(params, { signal }); | ||
| const result = response.choices[0].message?.content; | ||
|
|
||
| return result; | ||
| } | ||
|
|
||
| const aiIntegration = new DevExpress.aiIntegration({ | ||
| sendRequest({ prompt }) { | ||
| const controller = new AbortController(); | ||
| const signal = controller.signal; | ||
|
|
||
| const aiPrompt = [ | ||
| { role: 'system', content: prompt.system }, | ||
| { role: 'user', content: prompt.user }, | ||
| ]; | ||
|
|
||
| const promise = getAIResponse(aiPrompt, signal); | ||
|
|
||
| const result = { | ||
| promise, | ||
| abort: () => { | ||
| controller.abort(); | ||
| }, | ||
| }; | ||
|
|
||
| return result; | ||
| }, | ||
| }); | ||
|
|
||
| const createTrademarkTemplate = (vehicle) => { | ||
| const { | ||
| ID, | ||
| Name, | ||
| TrademarkName, | ||
| } = vehicle; | ||
dmlvr marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| const trademarkWrapper = $('<div>').addClass('trademark__wrapper'); | ||
| const imgWrapper = $('<div>').addClass('trademark__img-wrapper'); | ||
| const img = $('<img>').addClass('trademark__img'); | ||
| img.attr({ | ||
| src: `images/vehicles/image_${ID}.png`, | ||
dmlvr marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| alt: `${TrademarkName} ${Name}`, | ||
| }); | ||
|
|
||
| const popoverId = `popover-${ID}`; | ||
| const popoverWrapper = $('<div>'); | ||
| popoverWrapper.html(` | ||
dmlvr marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| <div class="license-info__title">License Information</div> | ||
| <div class="license-info__content"> | ||
dmlvr marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| <p><strong>Image:</strong> ${TrademarkName} ${Name}</p> | ||
| <p><strong>License:</strong> Stock Photo License</p> | ||
| <p><strong>Attribution:</strong> © DevExpress Demos</p> | ||
| <p><strong>Usage:</strong> For demonstration purposes only</p> | ||
| </div> | ||
| `); | ||
|
|
||
| img.attr('data-popover-target', popoverId); | ||
|
|
||
| const popover = $('<div>').attr('id', popoverId).dxPopover({ | ||
| target: `[data-popover-target="${popoverId}"]`, | ||
| showEvent: 'mouseenter', | ||
| hideEvent: 'mouseleave', | ||
| position: 'top', | ||
| contentTemplate: () => popoverWrapper, | ||
| }); | ||
|
|
||
| imgWrapper.append(img, popover); | ||
| trademarkWrapper.append(imgWrapper); | ||
|
|
||
| const textWrapper = $('<div>').addClass('trademark__text-wrapper'); | ||
| const trademarkText = $('<div>').addClass('trademark__text trademark__text--title').text(TrademarkName); | ||
| const nameText = $('<div>').addClass('trademark__text trademark__text--subtitle').text(Name); | ||
|
|
||
| textWrapper.append(trademarkText, nameText); | ||
| trademarkWrapper.append(textWrapper); | ||
|
|
||
| return trademarkWrapper; | ||
| }; | ||
|
|
||
| const createCategoryTemplate = ({ CategoryName }) => $('<div>').addClass('category__wrapper').text(CategoryName); | ||
|
|
||
| $('#gridContainer').dxDataGrid({ | ||
| dataSource: vehicles, | ||
| columns: [ | ||
| { | ||
| caption: 'Trademark', | ||
| width: 220, | ||
| cellTemplate: (container, options) => { | ||
| const vehicle = options.data; | ||
| const imageWrapper = createTrademarkTemplate(vehicle); | ||
| container.append(imageWrapper); | ||
| }, | ||
| }, | ||
| { | ||
| dataField: 'Price', | ||
| format: 'currency', | ||
| width: 100, | ||
| headerFilter: { | ||
dmlvr marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| groupInterval: 20000, | ||
| }, | ||
| }, | ||
| { | ||
| caption: 'Category', | ||
| cellTemplate: (container, options) => { | ||
| const category = options.data; | ||
| const categoryWrapper = createCategoryTemplate(category); | ||
| container.append(categoryWrapper); | ||
| }, | ||
| }, | ||
| { | ||
| dataField: 'Modification', | ||
| width: 180, | ||
| }, | ||
| { | ||
| dataField: 'Horsepower', | ||
| width: 140, | ||
| }, | ||
| { | ||
| dataField: 'BodyStyleName', | ||
| caption: 'Body Style', | ||
| width: 180, | ||
| }, | ||
| { | ||
| name: 'AI column', | ||
| caption: 'Origin Country', | ||
| type: 'ai', | ||
| ai: { | ||
| aiIntegration, | ||
dmlvr marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| prompt: 'show the country of origin for the following vehicles', | ||
dmlvr marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| mode: 'auto', | ||
| showHeaderMenu: true, | ||
| noDataText: 'No data', | ||
| emptyText: 'Unknown', | ||
| }, | ||
| width: 200, | ||
| fixed: true, | ||
| fixedPosition: 'right', | ||
| cellTemplate: ($container) => { | ||
| $container.addClass('ai__cell'); | ||
| }, | ||
| }, | ||
| ], | ||
| }); | ||
| }); | ||
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,71 @@ | ||
| .trademark__wrapper { | ||
| display: flex; | ||
| align-items: center; | ||
| gap: 8px; | ||
| } | ||
|
|
||
| .trademark__img-wrapper { | ||
| width: 40px; | ||
| height: 40px; | ||
| border: 1px solid #E0E0E0; | ||
| border-radius: 4px; | ||
| cursor: pointer; | ||
| transition: border-color 0.2s ease; | ||
| } | ||
|
|
||
| .trademark__img-wrapper img { | ||
| width: 100%; | ||
| height: 100%; | ||
| object-fit: cover; | ||
| object-position: center; | ||
| border-radius: 4px; | ||
| } | ||
|
|
||
| .trademark__text-wrapper { | ||
| width: calc(100% - 48px); | ||
| } | ||
|
|
||
| .trademark__text { | ||
| margin: 0; | ||
| padding: 0; | ||
| } | ||
|
|
||
| .trademark__text--title { | ||
| font-weight: 600; | ||
| } | ||
|
|
||
| .trademark__text--subtitle { | ||
| font-weight: 400; | ||
| } | ||
|
|
||
| .category__wrapper { | ||
| display: inline-block; | ||
| padding: 2px 8px; | ||
| background-color: #E0E0E0; | ||
| border-radius: 24px; | ||
| } | ||
|
|
||
| .ai__cell, .dx-command-ai { | ||
| background-color: #FAFAFA !important; | ||
dmlvr marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| } | ||
|
|
||
| .license-info__title { | ||
| font-size: 14px; | ||
| font-weight: 600; | ||
| margin-bottom: 8px; | ||
| color: #333; | ||
| border-bottom: 1px solid #E0E0E0; | ||
| padding-bottom: 6px; | ||
| } | ||
|
|
||
| .license-info__content p { | ||
| margin: 4px 0; | ||
| font-size: 12px; | ||
| line-height: 1.4; | ||
| color: #666; | ||
| } | ||
|
|
||
| .license-info__content strong { | ||
| color: #333; | ||
| font-weight: 500; | ||
| } | ||
dmlvr marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
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.