UI Widgets TileView

A widget displaying several blocks of data as tiles.

Included in: dx.phonejs.js, dx.all.js

The dxTileView widget displays objects of a different size and reorders them so that they fit on the screen.

This widget, like any other DevExtreme UI widget, can be created using one of three possible approaches: jQuery, Knockout or AngularJS. The following code demonstrates how to create the dxTileView widget using the Knockout approach.

HTML
<div data-bind="dxTileView:{dataSource: tileViewData, baseItemHeight: 150, baseItemWidth: 150}"></div>

The width and height of each tile's view element is a multiple of the base width and base height specified with the baseItemWidth and baseItemHeight configuration options, respectively. The base width and base height are specified in pixels.

Like a regular list, the tile view consists of items that can perform an associated action when clicked. The list items are loaded from an array specified from the dataSource configuration option. You can specify a simple array or an array of objects as the data source.

JavaScript
var tileViewData = [
      { name: "Alabama", capital: "Montgomery", population: 4822023, area: 135765 },
      { name: "Alaska", capital: "Juneau", population: 731449, area: 1717854 },
      { name: "Arizona", capital: "Phoenix", population: 6553255, area: 295254 },
      { name: "Arkansas", capital: "Little Rock", population: 2949131, area: 137002 },
      { name: "California", capital: "Sacramento", population: 38041430, area: 423970 },
      { name: "Colorado", capital: "Denver", population: 5187582, area: 269602 },
      { name: "Connecticut", capital: "Hartford", population: 3590347, area: 14356 }
      ...
 ];

To display the widget's items, a default template is applied based on the following fields of the data source item objects.

  • disabled
    Specifies whether or not the gallery item is disabled.
  • visible
    Specifies whether or not the gallery item is visible.
  • html
    Specifies the html code inserted into the item element.
  • text
    Specifies the text inserted into the item element.
  • heightRatio
    Specifies a multiplier for the baseItemHeight option value (for the purpose of obtaining the actual item height).
  • widthRatio
    Specifies a multiplier for the baseItemWidth option value (for the purpose of obtaining the actual item width).

You can introduce a custom template for tiles. For this purpose, add a div element with the data-options attribute set to dxTemplate. Assign item to the template name. In this instance, the template will be applied automatically. See the Customize Widget Item Appearance topic to learn more about templates.

HTML
<div data-bind="dxTileView:{dataSource: tileViewData, baseItemHeight: 150, baseItemWidth: 150}">
    <div data-options="dxTemplate:{name:'item'}">
        <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>
See Also
  • To learn how to create widgets in detail, refer to the Create a Widget article.
  • The dxTileView widget is related to the Collection Containers category. So read an overview of the features that are common for collection container widgets in the Common Tasks topic of the Collection Containers article.
Show Example:
jQuery
<div class="tileView" data-bind="dxTileView: {
  dataSource: tileViewDataSource,
  itemMargin: 20,
  baseItemHeight: 130,
  baseItemWidth: 180
}">
    <div class="tile" data-options="dxTemplate:{name:'item'}">
        <p style="font-size:larger;"><b data-bind="text: name"></b></p>
    <img style="margin:5px;" data-bind="attr: { src: getImagePath(name) }" />
        <p>Capital: <i data-bind="text: capital"></i></p>
    </div>
</div>
//An object passed to the dataSource configuration option of the tile view
tileViewDataSource = new DevExpress.data.DataSource("/Content/data/states.txt");

//Generates the path to the required image file
getImagePath = function (name) {
  return "/Content/images/doc/14_1/PhoneJS/flags/" + name.replace(" ", "") + ".gif";
};
.tile {
  border-radius: .5em;
  text-align: center;
  color: white;
  background: gray;
}

Configuration

An object defining configuration options for the dxTileView widget.

Methods

This section describes members used to manipulate the widget.

Events

This section describes events fired by this component.

Default Item Template

This section lists the data source fields that are used in a default template for tile view items.

By default, a predefined item template is applied to display items of DevExtreme collection widgets. This template is based on certain fields of the data source provided for a widget. Below is the list of the fields that take part in a default item template for the dxTileView widget. If the default item template is not appropriate for your task, implement a custom item template based on these or other fields of your data source. For details refer to the Customize Widget Item Appearance topic.