Angular Scheduler - Customize Resource Headers
For AngularJS and Knockout apps, DevExtreme provides the dxTemplate markup component. The following code shows how to use dxTemplate to define custom templates for resource headers.
- <dx-scheduler
- [dataSource]="schedulerData"
- [currentDate]="currentDate"
- [groups]="['roomId']"
- resourceCellTemplate="headerTemplate">
- <dxi-resource
- fieldExpr="roomId"
- [dataSource]="rooms" >
- </dxi-resource>
- <div *dxTemplate="let data of 'headerTemplate'">
- <i style="color: blue">{{data.text}}</i>
- </div>
- </dx-scheduler>
- import { DxSchedulerModule } from "devextreme-angular";
- // ...
- export class AppComponent {
- schedulerData = [{
- text: "Meeting",
- startDate: new Date("2016-04-24T09:10:00.000Z"),
- endDate: new Date("2016-04-24T11:20:00.000Z"),
- roomId: 1
- },
- // ...
- ];
- rooms = [
- { id: 1, text: 'Room101', color: 'green' },
- { id: 2, text: 'Room102', color: 'red' },
- // ...
- ];
- currentDate = new Date(2016, 4, 24);
- }
- @NgModule({
- imports: [
- // ...
- DxSchedulerModule
- ],
- // ...
- })
If you use jQuery alone, use DOM manipulation methods to combine the HTML markup for resource headers. To apply this markup, use the resourceCellTemplate callback function as shown in the following code.
- var schedulerData = [{
- text: "Meeting",
- startDate: new Date("2016-04-24T09:10:00.000Z"),
- endDate: new Date("2016-04-24T11:20:00.000Z"),
- roomId: 1
- },
- // ...
- ];
- var roomResource = {
- fieldExpr: 'roomId',
- dataSource: [
- { id: 1, text: 'Room101', color: 'green' },
- { id: 2, text: 'Room102', color: 'red' },
- // ...
- ]
- };
- $(function () {
- $("#schedulerContainer").dxScheduler({
- dataSource: schedulerData,
- currentDate: new Date(2016, 4, 24),
- resources: [ roomResource ],
- groups: [ 'roomId' ],
- resourceCellTemplate: function (data, index, element) {
- element.append("<i style='color: blue'>" + data.text + "</i>");
- }
- });
- });
In addition, you can use a 3rd-party template engine to customize UI component appearance. For more information, see the 3rd-Party Template Engines article.
See Also
If you have technical questions, please create a support ticket in the DevExpress Support Center.