11import React from 'react' ;
2- import { DataSource } from 'devextreme-react/common/data' ;
2+ import { CustomStore } from 'devextreme-react/common/data' ;
33import DataGrid , {
44 Column ,
55 Pager ,
66 Paging ,
77 FilterRow ,
8- Lookup
98} from 'devextreme-react/data-grid' ;
109import './tasks.scss' ;
1110
@@ -27,85 +26,61 @@ export function Tasks() {
2726 < Pager showPageSizeSelector = { true } showInfo = { true } />
2827 < FilterRow visible = { true } />
2928
30- < Column dataField = { 'Task_ID ' } width = { 90 } hidingPriority = { 2 } />
29+ < Column dataField = { 'id ' } width = { 90 } hidingPriority = { 1 } />
3130 < Column
32- dataField = { 'Task_Subject ' }
31+ dataField = { 'text ' }
3332 width = { 190 }
3433 caption = { 'Subject' }
35- hidingPriority = { 8 }
34+ hidingPriority = { 6 }
3635 />
3736 < Column
38- dataField = { 'Task_Status ' }
37+ dataField = { 'status ' }
3938 caption = { 'Status' }
40- hidingPriority = { 6 }
39+ hidingPriority = { 4 }
4140 />
4241 < Column
43- dataField = { 'Task_Priority' }
44- caption = { 'Priority' }
45- hidingPriority = { 5 }
46- >
47- < Lookup
48- dataSource = { priorities }
49- valueExpr = { 'value' }
50- displayExpr = { 'name' }
51- />
52- </ Column >
53- < Column
54- dataField = { 'ResponsibleEmployee.Employee_Full_Name' }
42+ dataField = { 'owner' }
5543 caption = { 'Assigned To' }
5644 allowSorting = { false }
57- hidingPriority = { 7 }
45+ hidingPriority = { 5 }
5846 />
5947 < Column
60- dataField = { 'Task_Start_Date ' }
48+ dataField = { 'startDate ' }
6149 caption = { 'Start Date' }
6250 dataType = { 'date' }
63- hidingPriority = { 3 }
51+ hidingPriority = { 2 }
6452 />
6553 < Column
66- dataField = { 'Task_Due_Date ' }
54+ dataField = { 'dueDate ' }
6755 caption = { 'Due Date' }
6856 dataType = { 'date' }
69- hidingPriority = { 4 }
57+ hidingPriority = { 3 }
7058 />
7159 < Column
72- dataField = { 'Task_Priority ' }
60+ dataField = { 'priority ' }
7361 caption = { 'Priority' }
7462 name = { 'Priority' }
75- hidingPriority = { 1 }
76- />
77- < Column
78- dataField = { 'Task_Completion' }
79- caption = { 'Completion' }
8063 hidingPriority = { 0 }
8164 />
8265 </ DataGrid >
8366 </ React . Fragment >
8467) }
8568
86- const dataSource = new DataSource ( {
87- store : {
88- version : 2 ,
89- type : 'odata' ,
90- key : 'Task_ID' ,
91- url : 'https://js.devexpress.com/Demos/DevAV/odata/Tasks'
92- } ,
93- expand : 'ResponsibleEmployee' ,
94- select : [
95- 'Task_ID' ,
96- 'Task_Subject' ,
97- 'Task_Start_Date' ,
98- 'Task_Due_Date' ,
99- 'Task_Status' ,
100- 'Task_Priority' ,
101- 'Task_Completion' ,
102- 'ResponsibleEmployee/Employee_Full_Name'
103- ]
104- } ) ;
69+ const dataSource = {
70+ store : new CustomStore ( {
71+ key : 'id' ,
72+ async load ( ) {
73+ try {
74+ const response = await fetch ( `https://js.devexpress.com/Demos/RwaService/api/Employees/AllTasks` ) ;
75+
76+ const result = await response . json ( ) ;
10577
106- const priorities = [
107- { name : 'High' , value : 4 } ,
108- { name : 'Urgent' , value : 3 } ,
109- { name : 'Normal' , value : 2 } ,
110- { name : 'Low' , value : 1 }
111- ] ;
78+ return {
79+ data : result ,
80+ } ;
81+ } catch {
82+ throw new Error ( `Data Loading Error` ) ;
83+ }
84+ } ,
85+ } )
86+ } ;
0 commit comments