DevExtreme jQuery/JS - Timetable

The Scheduler widget allows you to customize its timetable. You can specify the time period and a single cell's duration via the startDayHour, endDayHour, and cellDuration options. Using the firstDayOfWeek option, you can define the weekday that is shown first.

JavaScript
  • $(function() {
  • $("#schedulerContainer").dxScheduler({
  • dataSource: [{
  • text: "Website Re-Design Plan",
  • startDate: new Date(2016, 4, 25, 9, 30),
  • endDate: new Date(2016, 4, 25, 11, 30)
  • }, {
  • text: "Book Flights to San Fran for Sales Trip",
  • startDate: new Date(2016, 4, 25, 12, 0),
  • endDate: new Date(2016, 4, 25, 13, 0)
  • },
  • // ...
  • ],
  • currentDate: new Date(2016, 4, 25),
  • startDayHour: 8,
  • endDayHour: 19,
  • cellDuration: 60,
  • firstDayOfWeek: 1
  • });
  • });

You can also adjust cells' size in the table and around it using the DevExtreme CSS classes. For example, the .dx-scheduler-cell-sizes-horizontal and .dx-scheduler-cell-sizes-vertical classes specify the cells' width and height, respectively. These classes apply if the crossScrollingEnabled option is set to true.

CSS
  • #yourSchedulerID .dx-scheduler-cell-sizes-horizontal {
  • width: 200px;
  • }
  • #yourSchedulerID .dx-scheduler-cell-sizes-vertical {
  • height: 200px;
  • }

For a more detailed customization, define custom templates for cells, time scales, and date scales. DevExtreme provides the dxTemplate markup component for Angular, AngularJS and Knockout apps. The following code shows how to use dxTemplate to define templates for timetable parts:

If you use jQuery alone, use DOM manipulation methods to combine the HTML markup for time scales and date scales. To apply this markup, use the timeCellTemplate, dateCellTemplate and dataCellTemplate callback functions as shown in the following code:

JavaScript
  • var schedulerData = [{
  • text: "His Girl Friday",
  • startDate: new Date(2016, 4, 24, 9, 10),
  • endDate: new Date(2016, 4, 24, 11, 20)
  • }, {
  • text: "Royal Wedding",
  • startDate: new Date(2016, 4, 24, 10, 05),
  • endDate: new Date(2016, 4, 24, 11, 30)
  • },
  • // ...
  • ];
  •  
  • $(function () {
  • $("#schedulerContainer").dxScheduler({
  • dataSource: schedulerData,
  • currentDate: new Date(2016, 4, 24),
  • showAllDayPanel: false,
  • currentView: 'week',
  • dataCellTemplate: function(data, index, element) {
  • return $("<div />")
  • .css('width', '100%')
  • .css('height', '40px')
  • .css('background-color', 'rgba(86, 202, 133, 0.1)');
  • },
  • dateCellTemplate: function(data, index, element) {
  • element.text(data.text)
  • .css('color', 'green')
  • .css('font-weight', 'bold');
  • },
  • timeCellTemplate: function(data, index, element) {
  • element.text(data.text)
  • .css('color', 'green')
  • .css('font-style', 'italic');
  • }
  • });
  • });

View Demo

You can also use a 3rd-party template engine to customize widget appearance. See the 3rd-Party Template Engines article for more information.

See Also