UI Widgets MultiView

A widget used to display a view and to switch between several views.

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

The dxMultiView widget includes several items (views). These items are placed horizontally next to one another and navigated by panning to the left or right. The widget is often used together with the dxTabs widget to display tab contents.

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 dxMultiView widget using the Knockout approach.

HTML
<div data-bind="dxMultiView: { dataSource: items }">  </div>

The widget items are loaded from an array specified using the dataSource configuration option.

JavaScript
items = [
    {
        title: "Personal Data",
        firstName: "John",
        lastName: "Smith",
        birthYear: 1986,
        template: "personalData"
    },
    {
        title: "Contacts",
        phone: "(555)555-5555",
        email: "John.Smith@example.com",
        template: "contacts"
    },
    {
        title: "Address",
        state: "CA",
        city: "San Francisco",
        street: "Stanford Ave",
        template: "address"
    }
]

To display multi-view items, a default template is applied based on the following fields of the data source item objects.

  • disabled
    Specifies whether or not the item is disabled.
  • visible
    Specifies whether or not the item is visible.
  • html
    Specifies the html code inserted into the item element.
  • text
    Specifies the text inserted into the item element.
  • title
    Specifies the name of an item.

You can introduce a custom template or multiple templates for widget items. For this purpose, add a div element with the data-options attribute set to dxTemplate. Specify the required template name. See the Customize Widget Item Appearance topic to learn more about templates.

HTML
<div data-bind="dxMultiView: { dataSource: items }">
    <div data-options="dxTemplate : { name: 'personalData' } ">
        <h1 data-bind="text: $data.title"></h1>
        <p>Name: <b data-bind="text: $data.firstName"></b> <b data-bind="text: $data.lastName"></b></p>
        <p>Birth year: <b data-bind="text: $data.firstName"></b></p>
    </div>
    <div data-options="dxTemplate : { name: 'contacts' } ">
        <h1 data-bind="text: $data.title"></h1>
        <p>Phone: <b data-bind="text: $data.phone"></b></p>
        <p>e-mail: <b data-bind="text: $data.email"></b></p>
    </div>
    <div data-options="dxTemplate : { name: 'address' } ">
        <h1 data-bind="text: $data.title"></h1>
        <p>State: <b data-bind="text: $data.state"></b></p>
        <p>City: <b data-bind="text: $data.city"></b></p>
        <p>Street: <b data-bind="text: $data.street"></b></p>
    </div>
</div>
See Also
  • To learn how to create widgets in detail, refer to the Create a Widget article.
  • The dxMultiView 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 data-bind="dxTabs:{ dataSource: multiViewItems, selectedIndex: currentIndex }"></div>
<div data-bind="dxMultiView: {
    dataSource: multiViewItems,
    selectedIndex: currentIndex,
    height: 160
}">
    <div data-options="dxTemplate : { name: 'item' } ">
        <div style="margin:25px;">
            <h1 data-bind="text: $data.title"></h1>
            <p>&nbsp;</p>
            <div style="text-align:left;" data-bind="foreach: dataArray">
                <p><span data-bind="text: propertyKey"></span>: <b data-bind="text: propertyValue"></b></b></p>
            </div>
        </div>
    </div>
</div>
currentIndex = ko.observable(0);
multiViewItems = new DevExpress.data.DataSource({
    store: [
        {
            title: "Personal Data",
            data: {
                firstName: "John",
                lastName: "Smith",
                birthYear: 1986,
            }
        },
        {
            title: "Contacts",
            data: {
                phone: "(555)555-5555",
                email: "John.Smith@example.com",
            }
        },
        {
            title: "Address",
            data: {
                state: "CA",
                city: "San Francisco",
                street: "Stanford Ave",
            }
        }
    ],
    map: function (itemData) {
        itemData.text = itemData.title;
        itemData.dataArray = $.map(itemData.data, function (value, key) {
            return {
                propertyKey: key,
                propertyValue: value
            }
        });
        return itemData;
    }
})
body{
    text-align:center;
}

Configuration

An object defining configuration options for the dxMultiView 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 item template.

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 the 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. For details refer to the Customize Widget Item Appearance topic.