UI Widgets TileView

A widget displaying several blocks of data as tiles.

Included in: dx.mobile.js, dx.web.js, dx.viz-web.js, dx.all.js
Module: ui/tile_view
TileView interactive configuration
Copy code
$("#tileview").dxTileView({
});

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

You can create a widget using one of the following approaches.

  • jQuery
    Use the dxTileView jQuery plug-in.

    HTML
    <div id="tileView"></div>
    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 },
        ...
    ];
    $("#tileView").dxTileView({
        dataSource: tileViewData,
        itemMargin: 20,
        baseItemHeight: 130,
        baseItemWidth: 180
    });
  • Knockout
    Add a div element and apply the dxTileView binding to this element.

    HTML
    <div data-bind="dxTileView: {
        dataSource: tileViewData,
        itemMargin: 20,
        baseItemHeight: 130,
        baseItemWidth: 180
    }"></div>
  • AngularJS
    Add a div element and apply the dx-tile-view directive to this element.

    HTML
    <div dx-tile-view="{
        dataSource: tileViewData,
        itemMargin: 20,
        baseItemHeight: 130,
        baseItemWidth: 180
    }"></div>

Note that DevExtreme widgets require you to link the jQuery library to your application. If you use the Knockout or AngularJS approach, the Knockout or AngularJS library is also required. For detailed information on linking these libraries to your project, refer to the Installation article.

Since the TileView widget is used to display multiple items, it supports common Collection Container widget functionality. You can find detailed information on the principles of working with the widget in the dxTileView section of the Collection Container Widgets article.

View Demo

Show Example:
AngularJS
Knockout
jQuery
<div ng-controller="demoController">
    <div dx-tile-view="{
        dataSource: tileViewDataSource,
        itemMargin: 20,
        baseItemHeight: 130,
        baseItemWidth: 180
    }" dx-item-alias="itemObj">
        <div class="tile" data-options="dxTemplate:{ name:'item' }">
            <p style="font-size:larger;"><b>{{itemObj.name}}</b></p>
            <img style="margin:5px;" ng-attr-src="{{itemObj.imagePath}}" />
            <p>Capital: <i>{{itemObj.capital}}</i></p>
        </div>
    </div>
</div>
var myApp = angular.module('myApp', ['dx']);
myApp.controller("demoController", function ($scope) {
    $scope.tileViewDataSource = new DevExpress.data.DataSource({
        store: [],
        map: function (dataItem) {
            dataItem.imagePath = "/Content/images/doc/16_1/PhoneJS/flags/" + dataItem.name.replace(" ", "") + ".gif";
            return dataItem;
        }
    });
    $.get("/Content/data/states.txt", function (data) {
        for (var i = 0; i < data.length; i++)
            $scope.tileViewDataSource.store().insert(data[i]);
        $scope.tileViewDataSource.load();
    }, "json");
});
angular.element(document).ready(function () {
    angular.bootstrap(document, ['myApp']);
});
.tile {
    border-radius: .5em;
    text-align: center;
    color: white;
    background: gray;
}
<div 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: imagePath }" />
        <p>Capital: <i data-bind="text: capital"></i></p>
    </div>
</div>
var myViewModel = {
    tileViewDataSource: new DevExpress.data.DataSource({
        store: [],
        map: function (dataItem) {
            dataItem.imagePath = "/Content/images/doc/16_1/PhoneJS/flags/" + dataItem.name.replace(" ", "") + ".gif";
            return dataItem;
        }
    })
}
ko.applyBindings(myViewModel);
$.get("/Content/data/states.txt", function (data) {
    for (var i = 0; i < data.length; i++)
        myViewModel.tileViewDataSource.store().insert(data[i]);
    myViewModel.tileViewDataSource.load();
}, "json");
.tile {
    border-radius: .5em;
    text-align: center;
    color: white;
    background: gray;
}
<div id="myTileView"></div>
var tileViewDataSource = new DevExpress.data.DataSource({
    store: [],
    map: function (dataItem) {
        dataItem.imagePath = "/Content/images/doc/16_1/PhoneJS/flags/" + dataItem.name.replace(" ", "") + ".gif";
        return dataItem;
    }
});
$("#myTileView").dxTileView({
    dataSource: tileViewDataSource,
    itemMargin: 20,
    baseItemHeight: 130,
    baseItemWidth: 180,
    itemTemplate: function (itemData, itemIndex, itemElement) {
        itemElement.addClass("tile");
        itemElement.append('<p style="font-size:larger;"><b>' + itemData.name + '</b></p>');
        itemElement.append('<img style="margin: 5px;" src="' + itemData.imagePath + '"/>');
        itemElement.append('<p>Capital: <i>' + itemData.capital + '</i></p>');
    }
});
$.get("/Content/data/states.txt", function (data) {
    for (var i = 0; i < data.length; i++)
        tileViewDataSource.store().insert(data[i]);
    tileViewDataSource.load();
}, "json");
.tile {
    border-radius: .5em;
    text-align: center;
    color: white;
    background: gray;
}

Configuration

An object defining configuration options for the TileView widget.

Methods

This section describes members used to manipulate the widget.

Events

This section describes events fired by this widget.

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 the items of this widget. This template is based on certain fields of the data source provided for this widget. Below is a list of these fields. 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.

See Also