Skip to content

Commit b251635

Browse files
Merge pull request #4 from DevExpress-Examples/vue
Vue
2 parents 25cf2e7 + 3237102 commit b251635

9 files changed

Lines changed: 17133 additions & 45 deletions

File tree

Vue/package-lock.json

Lines changed: 13 additions & 13 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Vue/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"type": "module",
55
"private": true,
66
"scripts": {
7-
"dev": "vite",
7+
"dev": "vite --port 5050",
88
"prebuild": "devextreme-license --out src/devextreme-license.ts --force",
99
"build": "run-p type-check build-only",
1010
"preview": "vite preview",
@@ -14,8 +14,8 @@
1414
"lint": "eslint . --fix"
1515
},
1616
"dependencies": {
17-
"devextreme": "26.1.2-beta",
18-
"devextreme-vue": "26.1.2-beta",
17+
"devextreme": "26.1.3",
18+
"devextreme-vue": "26.1.3",
1919
"vue": "^3.2.45",
2020
"vue-router": "^4.1.6"
2121
},

Vue/src/assets/main.css

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
.main {
1+
body {
2+
margin: 0;
23
font-family: Avenir, Helvetica, Arial, sans-serif;
34
-webkit-font-smoothing: antialiased;
45
-moz-osx-font-smoothing: grayscale;
56
color: #2c3e50;
6-
margin: 50px 50px;
7-
width: 90vh;
8-
}
7+
}

Vue/src/components/HomeContent.vue

Lines changed: 159 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,167 @@
11
<script setup lang="ts">
2-
import { computed, ref } from 'vue';
2+
import { ref } from 'vue';
33
4-
import 'devextreme/dist/css/dx.material.blue.light.compact.css';
5-
import DxButton from 'devextreme-vue/button';
4+
import 'devextreme/dist/css/dx.fluent.blue.light.css';
5+
import DxDataGrid, {
6+
DxAI,
7+
DxAIAssistant,
8+
DxColumn,
9+
DxFilterRow,
10+
DxGroupPanel,
11+
DxHeaderFilter,
12+
DxPager,
13+
DxPaging,
14+
DxSearchPanel,
15+
} from 'devextreme-vue/data-grid';
16+
import type dxChat from 'devextreme/ui/chat';
17+
import type { DxChatTypes } from 'devextreme-vue/chat';
18+
import type { DxButtonGroupTypes } from 'devextreme-vue/button-group';
619
7-
const props = defineProps({
8-
text: {
9-
type: String,
10-
default: 'count',
20+
import AIService from '../service';
21+
import { AI_ASSISTANT_URL, AI_COLUMN_URL, sales } from '../data';
22+
23+
const HELP_PROMPT = `💡 The DataGrid AI Assistant allows you to control the component using natural language. You can execute commands such as the following:
24+
• Sort records
25+
• Apply a filter
26+
• Search for a specific value
27+
• Group records by a field
28+
• Focus and select rows
29+
• Modify paging settings
30+
• Pin, resize, and reorder columns
31+
• Configure data summaries
32+
• Pick a suggestion or enter a custom request to get started.`;
33+
34+
const allowedPageSizes = [10, 25, 50, 100];
35+
36+
const service = new AIService(AI_COLUMN_URL, AI_ASSISTANT_URL);
37+
const chatRef = ref<dxChat | null>(null);
38+
39+
const chatOptions = {
40+
onInitialized: (e: DxChatTypes.InitializedEvent) => {
41+
chatRef.value = e.component ?? null;
1142
},
12-
});
13-
const count = ref(0);
14-
const buttonText = computed < string > (
15-
() => `Click ${props.text}: ${count.value}`
16-
);
17-
function clickHandler() {
18-
count.value += 1;
19-
}
43+
user: { id: 'user' },
44+
suggestions: {
45+
items: [
46+
{ text: '💡 Help', prompt: HELP_PROMPT },
47+
{ text: '🔍 Filter Sector by Health', prompt: 'Filter Sector by Health' },
48+
{ text: '↕️ Sort by Region', prompt: 'Sort by Region' },
49+
{ text: '🧩 Group by Product', prompt: 'Group by Product', width: 170 },
50+
],
51+
onItemClick: (e: DxButtonGroupTypes.ItemClickEvent) => {
52+
const { prompt, text } = e.itemData;
53+
const userId = text === '💡 Help' ? 'help' : 'user';
54+
55+
const message = {
56+
id: Date.now(),
57+
timestamp: new Date(),
58+
author: { id: userId },
59+
text: prompt,
60+
};
61+
62+
chatRef.value
63+
?.getDataSource()
64+
.store()
65+
.push([
66+
{
67+
type: 'insert',
68+
data: message,
69+
},
70+
]);
71+
},
72+
},
73+
};
2074
</script>
75+
2176
<template>
22-
<div>
23-
<DxButton
24-
:text="buttonText"
25-
@click="clickHandler"
26-
/>
77+
<div class="demo-container">
78+
<DxDataGrid
79+
id="grid-container"
80+
:data-source="sales"
81+
:ai-integration="service.columnAiIntegration"
82+
:show-borders="true"
83+
key-expr="Id"
84+
:filter-sync-enabled="true"
85+
>
86+
<DxSearchPanel
87+
:visible="true"
88+
:width="240"
89+
placeholder="Search..."
90+
/>
91+
<DxGroupPanel :visible="true"/>
92+
<DxHeaderFilter :visible="true"/>
93+
<DxFilterRow :visible="true"/>
94+
<DxPaging :page-size="10"/>
95+
<DxPager
96+
:visible="true"
97+
:allowed-page-sizes="allowedPageSizes"
98+
:show-page-size-selector="true"
99+
/>
100+
101+
<DxAIAssistant
102+
:enabled="true"
103+
:ai-integration="service.assistantAiIntegration"
104+
:chat="chatOptions"
105+
/>
106+
107+
<DxColumn data-field="Product"/>
108+
<DxColumn
109+
data-field="Amount"
110+
caption="Sale Amount"
111+
data-type="number"
112+
format="currency"
113+
/>
114+
<DxColumn
115+
data-field="Region"
116+
data-type="string"
117+
/>
118+
<DxColumn
119+
data-field="Sector"
120+
data-type="string"
121+
/>
122+
<DxColumn
123+
data-field="SaleDate"
124+
data-type="date"
125+
/>
126+
<DxColumn
127+
data-field="Customer"
128+
data-type="string"
129+
/>
130+
<DxColumn
131+
name="AI column"
132+
caption="AI Column"
133+
type="ai"
134+
:width="200"
135+
:fixed="true"
136+
fixed-position="right"
137+
css-class="ai-cell"
138+
>
139+
<DxAI
140+
:prompt="`
141+
Identify the country where product is manufactured.
142+
When looking up a country, consider Sector and Customers.
143+
`"
144+
mode="auto"
145+
no-data-text="No data"
146+
/>
147+
</DxColumn>
148+
</DxDataGrid>
27149
</div>
28150
</template>
151+
152+
<style>
153+
.demo-container {
154+
display: flex;
155+
justify-content: center;
156+
margin: 20px;
157+
}
158+
159+
#grid-container {
160+
max-width: 1200px;
161+
width: 100%;
162+
}
163+
164+
#grid-container .ai-cell {
165+
background-color: var(--dx-datagrid-row-alternation-bg);
166+
}
167+
</style>

0 commit comments

Comments
 (0)