1- import {
2- NgModule , Component , ViewChild , enableProdMode ,
3- } from '@angular/core' ;
1+ import { NgModule , Component , ViewChild , enableProdMode } from '@angular/core' ;
42import { BrowserModule } from '@angular/platform-browser' ;
53import { platformBrowserDynamic } from '@angular/platform-browser-dynamic' ;
6-
7- import { DataSourceOptions } from 'devextreme-angular/common/data' ;
84import { DxDataGridComponent , DxDataGridModule , DxSelectBoxModule } from 'devextreme-angular' ;
5+ import { type DxSelectBoxTypes } from 'devextreme-angular/ui/select-box' ;
6+
7+ import { Service , Task } from './app.service' ;
98
109if ( ! / l o c a l h o s t / . test ( document . location . host ) ) {
1110 enableProdMode ( ) ;
@@ -22,37 +21,25 @@ if (window && window.config?.packageConfigPaths) {
2221 templateUrl : `.${ modulePrefix } /app.component.html` ,
2322 styleUrls : [ `.${ modulePrefix } /app.component.css` ] ,
2423 preserveWhitespaces : true ,
24+ providers : [ Service ] ,
2525} )
26-
2726export class AppComponent {
2827 @ViewChild ( DxDataGridComponent , { static : false } ) dataGrid : DxDataGridComponent ;
2928
30- statuses = [ 'All' , 'Not Started' , 'In Progress' , 'Need Assistance' , 'Deferred' , 'Completed' ] ;
29+ statuses : string [ ] ;
3130
32- tasks : DataSourceOptions = {
33- store : {
34- type : 'odata' ,
35- version : 2 ,
36- url : 'https://js.devexpress.com/Demos/DevAV/odata/Tasks' ,
37- key : 'Task_ID' ,
38- } ,
39- expand : 'ResponsibleEmployee' ,
40- select : [
41- 'Task_ID' ,
42- 'Task_Subject' ,
43- 'Task_Start_Date' ,
44- 'Task_Due_Date' ,
45- 'Task_Status' ,
46- 'Task_Priority' ,
47- 'ResponsibleEmployee/Employee_Full_Name' ,
48- ] ,
49- } ;
31+ tasks : Task [ ] ;
32+
33+ constructor ( private service : Service ) {
34+ this . statuses = this . service . getStatuses ( ) ;
35+ this . tasks = this . service . getTasks ( ) ;
36+ }
5037
51- selectStatus ( { value } ) {
52- if ( value === 'All' ) {
38+ selectStatus ( e : DxSelectBoxTypes . ValueChangedEvent ) {
39+ if ( e . value === 'All' ) {
5340 this . dataGrid . instance . clearFilter ( ) ;
5441 } else {
55- this . dataGrid . instance . filter ( [ 'Task_Status' , '=' , value ] ) ;
42+ this . dataGrid . instance . filter ( [ 'Task_Status' , '=' , e . value ] ) ;
5643 }
5744 }
5845}
0 commit comments