All docs
V19.1
24.1
The page you are viewing does not exist in version 24.1.
23.2
The page you are viewing does not exist in version 23.2.
23.1
The page you are viewing does not exist in version 23.1.
22.2
The page you are viewing does not exist in version 22.2.
22.1
The page you are viewing does not exist in version 22.1.
21.2
The page you are viewing does not exist in version 21.2.
21.1
The page you are viewing does not exist in version 21.1.
20.2
The page you are viewing does not exist in version 20.2.
20.1
The page you are viewing does not exist in version 20.1.
19.2
19.1
18.2
18.1
17.2
A newer version of this page is available. Switch to the current version.

DevExtreme jQuery - Customize Cell Appearance

For Angular, AngularJS, and Knockout apps, DevExtreme provides a markup component called dxTemplate. The following code shows how you can use dxTemplate to define templates for cells.

Angular
HTML
TypeScript
<dx-calendar
    [(value)]="currentDate">
    <span *dxTemplate="let cellData of 'cell'; let i = index"
         [style.font-style]="i == 0 || i == 6 ? 'italic' : 'normal'">
         {{cellData.text}}
    </span>
</dx-calendar>
import { DxCalendarModule } from "devextreme-angular";
// ...
export class AppComponent {
    currentDate: Date = new Date();
}
@NgModule({
    imports: [
        // ...
        DxCalendarModule
    ],
    // ...
})
AngularJS
HTML
JavaScript
<div ng-controller="DemoController">
    <div dx-calendar="{
        cellTemplate: 'cell',
        bindingOptions: {
            value: 'currentDate'
        }
    }" dx-item-alias="cellData">
        <span data-options="dxTemplate: { name: 'cell' }"
              style="font-style: {{$index == 0 || $index == 6 ? 'italic' : 'normal'}}">
              {{cellData.text}}
        </span>
    </div>
</div>
angular.module('DemoApp', ['dx'])
    .controller('DemoController', function DemoController($scope) {
        $scope.currentDate = new Date();
    });
NOTE
The dx-item-alias directive specifies the variable that is used to access the cell object.
Knockout
HTML
JavaScript
<div data-bind="dxCalendar: {
    value: currentDate,
    cellTemplate: 'cell'
}">
    <span data-options="dxTemplate: { name: 'cell' }" data-bind="{
        style: { 'font-style': $index == 0 || $index == 6 ? 'italic' : 'normal' },
        text: text
    }"></span>
</div>
var viewModel = {
    currentDate: ko.observable(new Date())
};

ko.applyBindings(viewModel);

If you use jQuery alone, combine the HTML markup for cells manually with jQuery DOM manipulation methods. To apply this markup, use the cellTemplate callback function as shown in the following code.

JavaScript
$(function () {
    $("#calendarContainer").dxCalendar({
        value: new Date(),
        cellTemplate: function (cellData, cellIndex, cellElement) {
            var italic = $("<span>").css('font-style', 'italic')
                                    .text(cellData.text);
            var normal = $("<span>").text(cellData.text);
            return (cellIndex == 0 || cellIndex == 6) ? italic : normal;
        }
    });
});

In addition, you can use a 3rd-party template engine to customize widget appearance. For more information, see the 3rd-Party Template Engines article.

See Also