Markup Components
This section describes components that can be used when defining a widget markup.
dxItem
Specifies markup for a widget item.
The dxItem component defines custom markup for a layout's or collection widget's item. The Default Item Template section of the widget describes each dxItem specified within the widget element and its configuration options.
-
HTML
<div id="navBarContainer"> <div data-options="dxItem: { disabled: true }"> <!-- custom markup --> </div> <div data-options="dxItem: { badge: 'New'}"> <!-- custom markup --> </div> <div data-options="dxItem: { }"> <!-- custom markup --> </div> </div>
-
HTML
<div dx-nav-bar="{ }"> <div data-options="dxItem: { disabled: true }"> <!-- custom markup --> </div> <div data-options="dxItem: { badge: 'New'}"> <!-- custom markup --> </div> <div data-options="dxItem: { }"> <!-- custom markup --> </div> </div>
-
HTML
<div data-bind="dxNavBar: { }"> <div data-options="dxItem: { disabled: true }"> <!-- custom markup --> </div> <div data-options="dxItem: { badge: 'New'}"> <!-- custom markup --> </div> <div data-options="dxItem: { }"> <!-- custom markup --> </div> </div>
dxTemplate
A markup component used to define markup options for a template.
The dxTemplate markup component is used to introduce a template markup for collection container widget items (List, Gallery, TileView, etc.) or container widgets (Popup, etc.) in Knockout and AngularJS applications. The template element should be contained in an element representing the required widget.
<!--Knockout--> <div data-bind="dxTileView: { dataSource: tileViewData, itemTemplate: 'tileTemplate' }"> <div data-options="dxTemplate: { name: 'tileTemplate' }"> <h1 data-bind="text: name"></h1> <p>Area: <i data-bind="text: area"></i> km2</p> <p>Population: <i data-bind="text: population"></i></p> <p>Capital: <i data-bind="text: capital"></i></p> </div> </div> <!--AngularJS--> <div dx-tile-view="{ dataSource: tileViewData, itemTemplate: 'tileTemplate' }" dx-item-alias="item"> <div data-options="dxTemplate: { name: 'tileTemplate' }"> <h1>{{item.name}}</h1> <p>Area: <i>{{item.area}}</i> km2</p> <p>Population: <i>{{item.population}}</i></p> <p>Capital: <i>{{item.capital}}</i></p> </div> </div>
dx-item-alias
directive. Add the directive to the widget element to specify an alias to the root object of an item (see the code above). Without this directive, item object fields are beyond reach.The dxTemplate component has a single option - "name". This is the template's identifier. Assign this name to the itemTemplate option of the widget in which the template is introduced. In this instance, this template will be applied to the widget items. However, the itemTemplate option has a specified default value, and you can use it as a name for the template. In this instance, you do not have to assign the template name to the widget's itemTemplate configuration option.
<div data-bind="dxRadioGroup:{dataSource: employees}"> <div data-options="dxTemplate: {name: 'item'}"> <span data-bind="text: name"></span> (hired at <span data-bind="text: hired"></span>) </div> </div>
A widget element can contain several template elements. In this instance, use the itemTemplate configuration option of the collection container widget to specify which template to use for rendering.
You can define special templates for specific devices. In addition, you can define multiple templates with the same name, which are targeted for different devices. To set a target device for a template, use the fields of the device object as markup options of dxTemplate.
<div data-options="dxTemplate: { name: 'item', platform: 'ios', phone: true }"> This is a template for an iPhone. </div> <div data-options="dxTemplate: { name: 'item', tablet: true }"> This is a template for any tablet. </div>
As you can see, you can specify the target platform as well as the device type.
If you have technical questions, please create a support ticket in the DevExpress Support Center.
We appreciate your feedback.