PivotGrid

The PivotGrid is a widget that allows you to display and analyze multi-dimensional data from a local storage or an OLAP cube.

Included in: dx.web.js, dx.viz-web.js, dx.all.js
Module: ui/pivot_grid
Export: default
PivotGrid interactive configuration
Copy Code
Copy to Codepen
$("#pivotgrid").dxPivotGrid({
});

                    

DevExtreme widgets are integrated with many popular libraries and frameworks. See the Installation section (for JavaScript libraries) or the Prerequisites and Installation section (for ASP.NET MVC framework) to find details on setting up DevExtreme with a particular library or framework.

The following code shows how to create the PivotGrid widget using every supported library and framework. For more details on working with widgets in these libraries and frameworks, see the Widget Basics topic for jQuery, Angular, AngularJS, Knockout or ASP.NET MVC.

jQuery
JavaScript
HTML
$(function () {
    $("#pivotGrid").dxPivotGrid({
        dataSource: {
            store: {
                type: 'odata',
                url: 'http://url/to/the/service',
                key: 'OrderID',
                keyType: 'Int32'
            },
            fields: [
                { area: 'column', dataField: 'OrderDate', dataType: 'date' },
                { area: 'row', dataField: 'ShipCountry' },
                { area: 'row', dataField: 'ShipCity' },
                { area: 'row', dataField: 'ShipName' },
                { area: 'data', summaryType: 'count' }
            ]
        }
    });
});
<div id="pivotGrid"></div>
Angular
HTML
TypeScript
<dx-pivot-grid>
    <dxo-data-source>
        <dxo-store
            type="odata"
            url="http://url/to/the/service"
            key="OrderID"
            keyType="Int32">
        </dxo-store>
    </dxo-data-source>
    <dxi-field
        area="column"
        dataField="OrderDate"
        dataType="date">
    </dxi-field>
    <dxi-field
        area="row"
        dataField="ShipCountry">
    </dxi-field>
    <dxi-field
        area="row"
        dataField="ShipCity">
    </dxi-field>
    <dxi-field
        area="row"
        dataField="ShipName">
    </dxi-field>
    <dxi-field
        area="data"
        summaryType="count">
    </dxi-field>
</dx-pivot-grid>
import { DxPivotGridModule } from 'devextreme-angular';
// ...
export class AppComponent {
    // ...
}
@NgModule({
    imports: [
        // ...
        DxPivotGridModule
    ],
    // ...
})
AngularJS
HTML
<div dx-pivot-grid="{
    dataSource: {
        store: {
            type: 'odata',
            url: 'http://url/to/the/service',
            key: 'OrderID',
            keyType: 'Int32'
        },
        fields: [
            { area: 'column', dataField: 'OrderDate', dataType: 'date'},
            { area: 'row', dataField: 'ShipCountry' },
            { area: 'row', dataField: 'ShipCity' },
            { area: 'row', dataField: 'ShipName' },
            { area: 'data', summaryType: 'count' }
        ]
    }
}"></div>
Knockout
HTML
<div data-bind="dxPivotGrid: {
    dataSource: {
        store: {
            type: 'odata',
            url: 'http://url/to/the/service',
            key: 'OrderID',
            keyType: 'Int32'
        },
        fields: [
            { area: 'column', dataField: 'OrderDate', dataType: 'date' },
            { area: 'row', dataField: 'ShipCountry' },
            { area: 'row', dataField: 'ShipCity' },
            { area: 'row', dataField: 'ShipName' },
            { area: 'data', summaryType: 'count' }
        ]
    }
}"></div>
ASP.NET MVC Controls
Razor C#
Razor VB
@(Html.DevExtreme().PivotGrid()
    .ID("pivotGrid")
    .DataSource(ds => ds
        .Store(store => store.OData()
            .Url("http://url/to/the/service")
            .Key(new string[] { "OrderID" })
            .KeyType(EdmType.Int32)
        )
        .Fields(fields => {
            fields.Add().Area(PivotGridArea.Column)
                .DataField("OrderDate")
                .DataType(PivotGridDataType.Date);
            fields.Add().Area(PivotGridArea.Row).DataField("ShipCountry");
            fields.Add().Area(PivotGridArea.Row).DataField("ShipCity");
            fields.Add().Area(PivotGridArea.Row).DataField("ShipName");
            fields.Add().Area(PivotGridArea.Data).SummaryType(SummaryType.Count);
        })
    )
)
@(Html.DevExtreme().PivotGrid() _
    .ID("pivotGrid") _
    .DataSource(Sub(ds)
        ds.Store(Function(store)
            Return store.OData() _
                .Url("http://url/to/the/service") _
                .Key(New String() { "OrderID" }) _
                .KeyType(EdmType.Int32)
            End Function) _
        .Fields(Sub(fields)
            fields.Add().Area(PivotGridArea.Column) _
                .DataField("OrderDate") _
                .DataType(PivotGridDataType.Date)
            fields.Add().Area(PivotGridArea.Row).DataField("ShipCountry")
            fields.Add().Area(PivotGridArea.Row).DataField("ShipCity")
            fields.Add().Area(PivotGridArea.Row).DataField("ShipName")
            fields.Add().Area(PivotGridArea.Data).SummaryType(SummaryType.Count)
        End Sub)
    End Sub)
)

To provide data for the PivotGrid widget, specify a data source. PivotGrid accepts the PivotGridDataSource data source only. You can pass its configuration to the dataSource field without creating the separate PivotGridDataSource object as shown above.

View Demo Watch Video

Configuration

This section describes the configuration options of the PivotGrid widget.

Methods

This section describes the methods that can be used to manipulate the PivotGrid widget.

Events

This section describes events fired by this widget.

See Also

Summary Cell

An object exposing methods that manipulate a summary cell and provide access to its neighboring cells.

Type:

Object

Pivot Grid Cell

An object containing information about the pivot grid cell.

Type:

Object