-
Notifications
You must be signed in to change notification settings - Fork 4
/
app.component.ts
46 lines (37 loc) · 1.17 KB
/
app.component.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import { Component, ViewChild } from "@angular/core";
import { DxSelectBoxComponent } from "devextreme-angular/ui/select-box";
import { State, City, Address, Service } from "./app.service";
@Component({
selector: "app-root",
templateUrl: "./app.component.html",
styleUrls: ["./app.component.css"],
providers: [Service]
})
export class AppComponent {
@ViewChild("citySelectBox", { static: false })
citySelectBoxComponent: DxSelectBoxComponent;
states: State[];
cities: City[];
selectedCityID: number;
address: Address;
constructor(service: Service) {
this.states = service.getStates();
this.cities = service.getCities();
this.address = service.getAddress();
}
onStateChanged(e) {
let dataSource = this.citySelectBoxComponent.instance.getDataSource();
dataSource.filter(["StateID", "=", e.value]);
dataSource.load();
this.selectedCityID = null;
}
onFieldDataChanged(e) {
if (e.dataField === "StateID") {
var cityEditor = e.component.getEditor("CityID");
let dataSource = cityEditor.getDataSource();
dataSource.filter(["StateID", "=", e.value]);
dataSource.load();
this.address.CityID = null;
}
}
}