UI Widgets Pivot

A widget that is similar to a traditional tab control, but optimized for the phone with simplified end-user interaction.

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

The dxPivot widget includes items (tabs). These items are placed horizontally next to one another and navigated by flicking or panning to the left or right, or by choosing the desired pivot header. While you always see the content of one item (tab), the pivot header of the next item is visible so users can clearly see that more items are available. This widget is often used to present lists of data filtered by different criteria. Although dxPivot was created based on the native WindowsPhone8 Pivot widget, it can be used on any platform.

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

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

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

JavaScript
items = [
    {
        title: "All",
        text: "All - description"
    },
    {
        title: "Family",
        text: "Family - description"
    },
    {
        title: "Friends",
        text: "Friends - description"
    },
    {
        title: "Work",
        text: "Work - description"
    }
]

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

  • disabled
    Specifies whether or not the pivot item is disabled.
  • visible
    Specifies whether or not the pivot item is visible
  • html
    Specifies the html code inserted into the item element
  • text
    Specifies the text inserted into the item element
  • title
    Specifies a name for a pivot item

To learn more about the fields used in the default item template, refer to the Default Item Template reference section of the widget.

You can introduce a custom template for pivot items. 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="dxPivot: { dataSource: items }">
    <div data-options="dxTemplate : { name: 'item' } ">
        <div data-bind="dxList: { dataSource: listItems }">
            <div data-options="dxTemplate : { name: 'item' } ">
                <div data-bind="text: name"></div>
                <div data-bind="text: phone"></div>
                <div data-bind="text: email"></div>
            </div>
        </div>
    </div>
</div>
See Also
  • To learn how to create widgets in detail, refer to the Create a Widget article.
  • The dxPivot 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.

Watch Video

Show Example:
jQuery
<div data-bind="dxPivot: { dataSource: items }">
    <div data-options="dxTemplate : { name: 'item' } ">
        <div data-bind="dxList: { dataSource: listItems }">
            <div data-options="dxTemplate : { name: 'item' } ">
                <div data-bind="text: name"></div>
                <div data-bind="text: phone"></div>
                <div data-bind="text: email"></div>
            </div>
        </div>
    </div>
</div>
contacts = [
        { name: "Barbara J. Coggins", phone: "512-964-2757", email: "BarbaraJCoggins@rhyta.com", category: "Family" },
        { name: "Carol M. Das", phone: "360-684-1334", email: "CarolMDas@jourrapide.com", category: "Friends" },
        { name: "Janet R. Skinner", phone: "520-573-7903", email: "JanetRSkinner@jourrapide.com", category: "Work" },
        { name: "Michael A. Blevins", phone: "530-480-1961", email: "MichaelABlevins@armyspy.com", category: "Favorites" },
        { name: "Jane K. Hernandez", phone: "404-781-0805", email: "JaneKHernandez@teleworm.us", category: "Friends" },
        { name: "Kim D. Thomas", phone: "603-583-9043", email: "KimDThomas@teleworm.us", category: "Work" },
        { name: "Angel H. Padgett", phone: "772-766-2842", email: "AngelHPadgett@jourrapide.com", category: "Family" },
        { name: "Donald L. Jordan", phone: "213-812-8400", email: "DonaldLJordan@dayrep.com", category: "Friends" },
        { name: "Barbara M. Roberts", phone: "614-365-7945", email: "BarbaraMRoberts@armyspy.com", category: "Friends" },
        { name: "Leslie S. Alcantara", phone: "313-881-9719", email: "LeslieSAlcantara@teleworm.us", category: "Work" },
        { name: "Chad S. Miles", phone: "269-718-9780", email: "ChadSMiles@rhyta.com", category: "Friends" },
        { name: "Sherryl C. Flowers", phone: "919-469-3285", email: "SherrylCFlowers@armyspy.com", category: "Friends" },
        { name: "Merle L. Stearns", phone: "213-995-1064", email: "MerleLStearns@jourrapide.com", category: "Friends" },
        { name: "Nicole A. Rios", phone: "240-416-4329", email: "NicoleARios@armyspy.com", category: "Friends" },
        { name: "James L. Parker", phone: "949-265-2198", email: "JamesLParker@teleworm.us", category: "Friends" },
        { name: "Erin G. Goodson", phone: "425-208-5408", email: "ErinGGoodson@rhyta.com", category: "Friends" },
        { name: "Lelia J. Stewart", phone: "580-302-0390", email: "LeliaJStewart@rhyta.com", category: "Family" },
        { name: "Debra B. Abbott", phone: "806-675-3359", email: "DebraBAbbott@jourrapide.com", category: "Work" },
        { name: "Sandra M. Perez", phone: "586-920-6315", email: "SandraMPerez@dayrep.com", category: "Friends" },
        { name: "Elaine R. Coats", phone: "262-397-2323", email: "ElaineRCoats@rhyta.com", category: "Friends" }
];

items = [
    {
        title: "All",
        listItems: new DevExpress.data.DataSource({
            store: contacts, sort: "name"
        })
    },
    {
        title: "Family",
        listItems: new DevExpress.data.DataSource({
            store: contacts, sort: "name", filter: ["category", "=", "Family"]
        })
    },
    {
        title: "Friends",
        listItems: new DevExpress.data.DataSource({
            store: contacts, sort: "name", filter: ["category", "=", "Friends"]
        })
    },
    {
        title: "Work",
        listItems: new DevExpress.data.DataSource({
            store: contacts, sort: "name", filter: ["category", "=", "Work"]
        })
    }
]

Configuration

An object defining configuration options for the dxPivot 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 pivot 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 dxPivot 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.