<dx-scheduler
[dataSource]="dataSource"
[timeZone]="currentLocation"
[views]="['workWeek']"
currentView="workWeek"
[startDayHour]="8"
[currentDate]="currentDate"
[resources]="resources"
[height]="600"
(onAppointmentFormOpening)="onAppointmentFormOpening($event)">
<dxi-resource
fieldExpr="startDateTimeZone"
valueExpr="value"
[dataSource]="locations">
</dxi-resource>
</dx-scheduler>
<div class="options">
<div class="caption">Options</div>
<div class="option">
<span>Office Location</span>
<dx-select-box
[items]="locations"
[width]="200"
displayExpr="text"
valueExpr="value"
[(value)]="currentLocation"
(onValueChanged)="onValueChanged($event)">
</dx-select-box>
</div>
</div>
import { NgModule, Component, enableProdMode } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { DxSchedulerModule, DxSelectBoxModule, DxTemplateModule } from 'devextreme-angular';
import { Service, Location } from './app.service';
import DataSource from 'devextreme/data/data_source';
if(!/localhost/.test(document.location.host)) {
enableProdMode();
}
@Component({
selector: 'demo-app',
templateUrl: 'app/app.component.html',
styleUrls: ['app/app.component.css'],
providers: [Service],
preserveWhitespaces: true
})
export class AppComponent {
dataSource: any;
currentDate: Date = new Date(2017, 4, 25);
currentLocation: any;
locations: Location[];
constructor(service: Service) {
this.locations = service.getLocations();
this.currentLocation = this.locations[0].value;
this.dataSource = new DataSource({
store: service.getData(),
filter: ["startDateTimeZone", this.currentLocation]
});
}
onAppointmentFormOpening(e) {
e.form.itemOption("startDateTimeZone", { visible: true });
e.form.itemOption("endDateTimeZone", { visible: true });
}
onValueChanged(e) {
this.dataSource.filter(["startDateTimeZone", e.value]);
}
}
@NgModule({
imports: [
BrowserModule,
DxSchedulerModule,
DxTemplateModule,
DxSelectBoxModule
],
declarations: [AppComponent],
bootstrap: [AppComponent]
})
export class AppModule { }
platformBrowserDynamic().bootstrapModule(AppModule);
::ng-deep .options {
padding: 20px;
background-color: rgba(191, 191, 191, 0.15);
margin-top: 20px;
}
::ng-deep .caption {
font-size: 18px;
font-weight: 500;
}
::ng-deep .option {
margin-top: 10px;
}
::ng-deep .option > span {
position: relative;
top: 2px;
margin-right: 10px;
}
::ng-deep .option > .dx-selectbox {
display: inline-block;
vertical-align: middle;
}
import { Injectable } from '@angular/core';
export class Data {
text: string;
startDate: string;
endDate: string;
recurrenceRule?: string;
startDateTimeZone: string;
endDateTimeZone: string
}
export class Location {
value: string;
text: string;
color: string;
}
let data: Data[] = [
{
text: "Stand-up meeting",
startDate: "2017-05-22T15:30:00.000Z",
endDate: "2017-05-22T15:45:00.000Z",
recurrenceRule: "FREQ=DAILY",
startDateTimeZone: "America/Los_Angeles",
endDateTimeZone: "America/Los_Angeles"
}, {
text: "Website Re-Design Plan",
startDate: "2017-05-23T16:30:00.000Z",
endDate: "2017-05-23T18:30:00.000Z",
startDateTimeZone: "America/Los_Angeles",
endDateTimeZone: "America/Los_Angeles"
}, {
text: "Book Flights to San Fran for Sales Trip",
startDate: "2017-05-24T18:00:00.000Z",
endDate: "2017-05-24T19:00:00.000Z",
startDateTimeZone: "America/Los_Angeles",
endDateTimeZone: "America/Los_Angeles"
}, {
text: "Install New Router in Dev Room",
startDate: "2017-05-25T17:00:00.000Z",
endDate: "2017-05-25T21:30:00.000Z",
startDateTimeZone: "America/Los_Angeles",
endDateTimeZone: "America/Los_Angeles"
}, {
text: "Approve Personal Computer Upgrade Plan",
startDate: "2017-05-26T16:00:00.000Z",
endDate: "2017-05-26T17:00:00.000Z",
startDateTimeZone: "America/Los_Angeles",
endDateTimeZone: "America/Los_Angeles"
}, {
text: "New Brochures",
startDate: "2017-05-26T19:30:00.000Z",
endDate: "2017-05-26T20:45:00.000Z",
startDateTimeZone: "America/Los_Angeles",
endDateTimeZone: "America/Los_Angeles"
}, {
text: "Daily meeting",
startDate: "2017-05-22T12:30:00.000Z",
endDate: "2017-05-22T12:45:00.000Z",
recurrenceRule: "FREQ=DAILY",
startDateTimeZone: "America/New_York",
endDateTimeZone: "America/New_York"
}, {
text: "Website Re-Design Plan",
startDate: "2017-05-23T13:30:00.000Z",
endDate: "2017-05-23T14:30:00.000Z",
startDateTimeZone: "America/New_York",
endDateTimeZone: "America/New_York"
}, {
text: "Book Flights to San Fran for Sales Trip",
startDate: "2017-05-24T14:00:00.000Z",
endDate: "2017-05-24T15:00:00.000Z",
startDateTimeZone: "America/New_York",
endDateTimeZone: "America/New_York"
}, {
text: "Install New Router in Dev Room",
startDate: "2017-05-25T14:30:00.000Z",
endDate: "2017-05-25T17:30:00.000Z",
startDateTimeZone: "America/New_York",
endDateTimeZone: "America/New_York"
}, {
text: "Approve Personal Computer Upgrade Plan",
startDate: "2017-05-23T15:00:00.000Z",
endDate: "2017-05-23T16:00:00.000Z",
startDateTimeZone: "America/New_York",
endDateTimeZone: "America/New_York"
}, {
text: "New Brochures",
startDate: "2017-05-26T13:30:00.000Z",
endDate: "2017-05-26T14:45:00.000Z",
startDateTimeZone: "America/New_York",
endDateTimeZone: "America/New_York"
}, {
text: "Upgrade Personal Computers",
startDate: "2017-05-26T15:15:00.000Z",
endDate: "2017-05-26T16:30:00.000Z",
startDateTimeZone: "America/New_York",
endDateTimeZone: "America/New_York"
}, {
text: "Prepare 2017 Marketing Plan",
startDate: "2017-05-22T07:00:00.000Z",
endDate: "2017-05-22T09:30:00.000Z",
startDateTimeZone: "Europe/Berlin",
endDateTimeZone: "Europe/Berlin"
}, {
text: "Launch New Website",
startDate: "2017-05-24T08:00:00.000Z",
endDate: "2017-05-24T10:00:00.000Z",
startDateTimeZone: "Europe/Berlin",
endDateTimeZone: "Europe/Berlin"
}, {
text: "Submit New Website Design",
startDate: "2017-05-25T09:30:00.000Z",
endDate: "2017-05-25T11:00:00.000Z",
startDateTimeZone: "Europe/Berlin",
endDateTimeZone: "Europe/Berlin"
}, {
text: "Upgrade Server Hardware",
startDate: "2017-05-26T06:30:00.000Z",
endDate: "2017-05-26T08:00:00.000Z",
startDateTimeZone: "Europe/Berlin",
endDateTimeZone: "Europe/Berlin"
}, {
text: "Approve New Online Marketing Strategy",
startDate: "2017-05-26T11:00:00.000Z",
endDate: "2017-05-26T12:30:00.000Z",
startDateTimeZone: "Europe/Berlin",
endDateTimeZone: "Europe/Berlin"
}, {
text: "Final Budget Review",
startDate: "2017-05-23T09:00:00.000Z",
endDate: "2017-05-23T10:35:00.000Z",
startDateTimeZone: "Europe/Berlin",
endDateTimeZone: "Europe/Berlin"
}];
let locations: Location[] = [{
value: "America/Los_Angeles",
text: "Los Angeles",
color: "#1e90ff"
}, {
value: "America/New_York",
text: "New York",
color: "#56ca85"
}, {
value: "Europe/Berlin",
text: "Berlin",
color: "#ff9747"
}];
@Injectable()
export class Service {
getLocations() {
return locations;
}
getData() {
return data;
}
}
// In real applications, you should not transpile code in the browser. You can see how to create your own application with Angular and DevExtreme here:
// https://js.devexpress.com/Documentation/Guide/Angular_Components/Getting_Started/Create_a_DevExtreme_Application/
System.config({
transpiler: 'ts',
typescriptOptions: {
module: "commonjs",
emitDecoratorMetadata: true,
experimentalDecorators: true
},
meta: {
'typescript': {
"exports": "ts"
}
},
paths: {
'npm:': 'https://unpkg.com/'
},
map: {
'ts': 'npm:plugin-typescript@8.0.0/lib/plugin.js',
'typescript': 'npm:typescript@3.4.5/lib/typescript.js',
'@angular/core': 'npm:@angular/core@8.0.0/bundles/core.umd.js',
'@angular/common': 'npm:@angular/common@8.0.0/bundles/common.umd.js',
'@angular/compiler': 'npm:@angular/compiler@8.0.0/bundles/compiler.umd.js',
'@angular/platform-browser': 'npm:@angular/platform-browser@8.0.0/bundles/platform-browser.umd.js',
'@angular/platform-browser-dynamic': 'npm:@angular/platform-browser-dynamic@8.0.0/bundles/platform-browser-dynamic.umd.js',
'@angular/router': 'npm:@angular/router@8.0.0/bundles/router.umd.js',
'@angular/forms': 'npm:@angular/forms@8.0.0/bundles/forms.umd.js',
'@angular/common/http': 'npm:@angular/common@8.0.0/bundles/common-http.umd.js',
'tslib': 'npm:tslib/tslib.js',
'rxjs': 'npm:rxjs@6.3.3',
'rxjs/operators': 'npm:rxjs@6.3.3/operators',
'devextreme': 'npm:devextreme@19.2',
'jszip': 'npm:jszip@3.1.3/dist/jszip.min.js',
'quill': 'npm:quill@1.3.7/dist/quill.js',
'devexpress-diagram': 'npm:devexpress-diagram',
'devexpress-gantt': 'npm:devexpress-gantt',
'devextreme-angular': 'npm:devextreme-angular@19.2'
},
packages: {
'app': {
main: './app.component.ts',
defaultExtension: 'ts'
},
'devextreme': {
defaultExtension: 'js'
},
'rxjs': { main: 'index.js', defaultExtension: 'js' },
'rxjs/operators': { main: 'index.js', defaultExtension: 'js' },
'devextreme-angular': {
main: 'index.js',
defaultExtension: 'js'
}
}
});
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>DevExtreme Demo</title>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0" />
<link rel="stylesheet" type="text/css" href="https://cdn3.devexpress.com/jslib/19.2.4/css/dx.common.css" />
<link rel="stylesheet" type="text/css" href="https://cdn3.devexpress.com/jslib/19.2.4/css/dx.light.css" />
<script src="https://unpkg.com/core-js@2.4.1/client/shim.min.js"></script>
<script src="https://unpkg.com/zone.js@0.6.25/dist/zone.js"></script>
<script src="https://unpkg.com/reflect-metadata@0.1.3/Reflect.js"></script>
<script src="https://unpkg.com/systemjs@0.21.3/dist/system.js"></script>
<script src="config.js"></script>
<script>
System.import('app').catch(console.error.bind(console));
</script>
</head>
<body class="dx-viewport">
<div class="demo-container">
<demo-app>Loading...</demo-app>
</div>
</body>
</html>