@@ -13,6 +13,7 @@ import DataGrid, {
1313} from "devextreme-react/data-grid" ;
1414import DiscountCell from "./DiscountCell" ;
1515import ODataStore from "devextreme/data/odata/store" ;
16+ import { AIIntegration } from 'devextreme-react/common/ai-integration' ;
1617
1718const columnOptions = {
1819 regularColumns : [
@@ -252,22 +253,85 @@ export const ColumnReordering: Story = {
252253 allowColumnDragging : true ,
253254 } ,
254255 }
255- }
256+ } ;
256257
257- const generatedData = generateData ( 10 , 100 ) ;
258+ const generatedData = generateData ( 10 , 100 ) ;
258259
259- export const ColumnReorderingWithVirtualColumns : Story = {
260- argTypes : {
261- columns : {
262- control : 'object' ,
263- mapping : null ,
264- } ,
260+ export const ColumnReorderingWithVirtualColumns : Story = {
261+ argTypes : {
262+ columns : {
263+ control : 'object' ,
264+ mapping : null ,
265265 } ,
266+ } ,
267+ args : {
268+ allowColumnReordering : true ,
269+ rtlEnabled : false ,
270+ columnWidth : 100 ,
271+ dataSource : generatedData ,
272+ columns : Object . keys ( generatedData [ 0 ] ) ,
273+ }
274+ }
275+
276+ export const AiColumn : Story = {
266277 args : {
278+ dataSource : countries ,
279+ columns : [
280+ {
281+ caption : 'AI Column 1' ,
282+ type : 'ai' ,
283+ name : 'test' ,
284+ ai : {
285+ aiIntegration : new AIIntegration ( {
286+ sendRequest ( ) {
287+ return {
288+ promise : new Promise ( ( resolve ) => {
289+ setTimeout ( ( ) => {
290+ resolve ( '{"text":"Test response from AI Column 1"}' ) ;
291+ } , 5000 ) ;
292+ } ) ,
293+ abort : ( ) => {
294+ } ,
295+ } ;
296+ } ,
297+ } ) ,
298+ } ,
299+ } ,
300+ 'Country' , 'Area' , 'Population_Urban' , 'Population_Rural' ,
301+ {
302+ caption : 'AI Column 2' ,
303+ type : 'ai' ,
304+ name : 'test' ,
305+ ai : {
306+ aiIntegration : new AIIntegration ( {
307+ sendRequest ( ) {
308+ return {
309+ promise : new Promise ( ( resolve ) => {
310+ setTimeout ( ( ) => {
311+ resolve ( '{"text":"Test response from AI Column 2"}' ) ;
312+ } , 5000 ) ;
313+ } ) ,
314+ abort : ( ) => {
315+ } ,
316+ } ;
317+ } ,
318+ } ) ,
319+ } ,
320+ }
321+ ] ,
322+ allowColumnResizing : true ,
267323 allowColumnReordering : true ,
268- rtlEnabled : false ,
269- columnWidth : 100 ,
270- dataSource : generatedData ,
271- columns : Object . keys ( generatedData [ 0 ] ) ,
324+ onContextMenuPreparing : ( e ) => {
325+ if ( e . target === 'header' && e . column ?. type === 'ai' ) {
326+ e . items = e . items || [ ] ;
327+ e . items . push ( {
328+ text : 'Show AI Prompt Editor' ,
329+ onItemClick : ( ) => {
330+ // @ts -expect-error
331+ e . component . getView ( 'aiColumnView' ) . showPromptEditor ( e . event . target , e . column ) ;
332+ } ,
333+ } ) ;
334+ }
335+ }
272336 }
273- }
337+ } ;
0 commit comments