Data Binding

The dxPivotGrid widget can present data obtained from different sources. You can declare an array of plain objects or get data from a remote server - dxPivotGrid will operate with any source quickly and seamlessly. In this guide, you will learn about different ways of providing and binding data to the dxPivotGrid widget.

Before you begin, please make sure you have successfully linked the necessary libraries and added the dxPivotGrid widget to your page. If not, start by learning how to do this using the Installation topic.

NOTE: You can configure the dxPivotGrid widget using the jQuery, Knockout or AngularJS approach. Code snippets in this guide use the jQuery approach.

See Also

Provide Data

DevExtreme is supplied with a set of components called "data library" that helps you read data from different sources. A comprehensive overview of data library features is provided in the Data Layer topic. There are two main concepts, which the data library is built on: DataSource and Store.

DataSource is a stateful object that keeps sorting, grouping, filtering, etc., and applies them each time data is loaded. It also provides events intended to handle data and state changes. More information on the DataSource object can be found in the Reference section.

NOTE: The dxPivotGrid widget accepts a special DataSource type called PivotGridDataSource.

Store is a universal data access interface supporting a number of methods for reading data. You can find the list of these methods in the What Are Stores topic. There are five predefined types of Stores used in dxPivotGrid.

  • ArrayStore - provides access to an in-memory array
  • LocalStore - provides access to the HTML5 web storage
  • ODataStore - provides access to a remote OData service
  • XmlaStore - provides access to a remote OLAP server
  • CustomStore - allows you to implement your own data access logic

dxPivotGrid accepts a PivotGridDataSource instance or a PivotGridDataSource configuration object. The instance or the object must have the store field specified (except for a CustomStore, where all Store settings are specified directly in the object). This field can be set to an object configuring a Store of any type listed above. In further subtopics, you will see configuration examples for using a Store of each type.

You can use one of the two available approaches for providing data for dxPivotGrid.

  • The first approach is processing the raw data on the client side by the dxPivotGrid widget. This approach should be used when the amount of data is several million records and less, otherwise local data processing will cause significant delays. This approach is discussed in greater detail in the Using the Client-Side Processing section.

  • The second approach is remote data processing on an OLAP server. This approach allows you to work with a large amount of data (several millions records and more) without delays. For more information on this approach, see the Using an OLAP section.

Using the Client-Side Processing

Client-side data processing is used for working with data whose amounts are close to one million records and which can be processed locally in an acceptable time frame. There are four Store types that support this approach. The specifics of using each Store type are detailed in the sections below.

Using an ArrayStore

This type of store is great when you need a simple data source with the data lifetime equaling the lifetime of your application. An ArrayStore is created from an array of plain objects. The code snippet below illustrates the minimal configuration of an ArrayStore that can be used to provide data for the dxPivotGrid widget.

var pivotGridDataSource = {
    store: {
        type: 'array',
        data: [
            {   "CustomerID": "WELLI",
                "OrderDate": "2010/07/15",
                "ShipAddress": "Rua do Mercado, 12",
                "ShipCity": "Resende",
                "ShipRegion": "SP",
                "ShipCountry": "Brazil",
                "Freight": 13.97
                "CustomerID": "TOMSP",
                "OrderDate": "2010/07/05",
                "ShipAddress": "Luisenstr, 48",
                "ShipCity": "Munster",
                "ShipRegion": null,
                "ShipCountry": "Germany",
                "Freight": 11.61
                "CustomerID": "HANAR",
                "OrderDate": "2010/07/08",
                "ShipAddress": "Rua do Paco, 67",
                "ShipCity": "Rio de Janeiro",
                "ShipRegion": "RJ",
                "ShipCountry": "Brazil",
                "Freight": 65.83

After you have created a data source configuration object, you need to bind it to your grid. Refer to the Bind Data section to learn how to do this.

Using a LocalStore

This type of Store is helpful when you use an HTML5 Web Storage (also known as window.localStorage) for storing your data. To provide a minimal configuration for a LocalStore, specify its type and name options as demonstrated below.

var pivotGridDataSource = {
    store: {
        type: 'local',
        name: 'myLocalStore'

After you have created a data source configuration object, you need to bind it to your grid. Refer to the Bind Data section to learn how to do this.

Using an ODataStore

OData is a universal open protocol for consuming data APIs. The DevExtreme data library provides a special type of Store to access OData web services, called ODataStore. The following code is sufficient to provide data for dxPivotGrid using an ODataStore.

var pivotGridDataSource = {
    store: {
        type: 'odata',
        url: 'http://url/to/the/source'

An ODataStore has many more options available for configuring. For the full list, refer to the ODataStore reference section.

After you have created a data source configuration object, you need to bind it to your grid. Refer to the Bind Data section to learn how to do this.

Using a CustomStore

When you have a custom web service with its own data accessing logic, use a CustomStore to operate data. This type of Store requires the implementation of a function for each data access operation. To use a CustomStore in dxPivotGrid, implement the load function specifying how data must be loaded from your web service. In this function, create a Deferred object. Then, get data from your web service. After data has been obtained successfully, resolve the Deferred object with received data and an additional object. The following code snippet shows how to do this. In this example, the getJSON function is used to acquire data.

var pivotGridDataSource = {
    load: function (loadOptions) {
        var d = $.Deferred();
        $.getJSON('').done(function (data) {
            // process data here
        return d.promise();

A CustomStore has many more configuration options than those described in this topic. For a complete list, refer to the CustomStore reference section.

After you have created a data source configuration object, bind it to your grid. Refer to the Bind Data section to learn how to do this.

Using an OLAP

DevExtreme is supplied with the XmlaStore Store type, which is used to interact with OLAP servers using an XMLA standard. If you intended to use OLAP technology for analyzing your data with the Pivot Grid widget, follow the steps below and you will learn how to configure the Microsoft Analysis Services and connect the dxPivotGrid widget to it.

NOTE: If you use another OLAP server that supports an XMLA standard, refer to the documentation for this server and learn how to configure HTTP access to it, then jump to step 6 of the list below.

1. Install Microsoft Analysis Services. For details, refer to the How to: Install Analysis Services by Using Setup MSDN article.

2. Install SQL Server Data Tools ― Business Intelligence for your version of Visual Studio (Visual Studio 2012 version).

3. Create a new project and define a Cube. For details, refer to the Multidimensional Modeling MSDN tutorial. If you would like to use sample data instead of your own, refer to the Install Sample Data and Projects MSDN article.

4. Configure HTTP access to the Analysis Services. For details, refer to the Configure HTTP Access to Analysis Services on Internet Information Services (IIS) 8.0 MSDN article.

5. Configure IIS to allow cross-domain access to the OLAP application created in step 4.

NOTE: IIS configuration for cross-domain authenticated access is not considered in this article. For educational purposes, please use the Anonymous authentication type or configure the OLAP server at the same domain with the IIS server.

 5.1. Add the HTTP Response Headers. In the OLAP application, in the Home pane, double-click HTTP Response Headers. Add the following custom headers.

  • Name: "Access-Control-Allow-Headers", Value: "Content-Type"
  • Name: "Access-Control-Allow-Methods", Value: "POST"
  • Name: "Access-Control-Allow-Origin" , Value: <the host from which you are going to access this server or "*" for all hosts>

 5.2. While configuring HTTP access, you added an "OLAP" script map to the OLAP application (Step 3, items 6-8 of the Configure HTTP Access to Analysis Services on Internet Information Services (IIS) 8.0 MSDN article). To make the cross-domain access work, make sure the "OPTIONSVerbHandler" is at the top of the Handler Mappings list. To access the list's order, click View Ordered List... from the Actions menu. If the "OPTIONSVerbHandler" is not at the top of the list, select the "OPTIONSVerbHandler" and use the Move Up command from the Actions menu to move it to the top. Also make sure the OLAP handler is located above other *.dll handlers (even the disabled ones).

6. Configure the dxPivotGrid | dataSource | store object for using your OLAP server. To learn how to display data from an OLAP cube in the pivot grid, refer to the Use OLAP Data for PivotGrid tutorial.

Bind Data

Regardless of the approach you've chosen to provide data, after implementing a data source, bind it to the dxPivotGrid widget using the dataSource option as demonstrated below.

It is also recommended that you declare the fields array and describe data from the DataSource for the Pivot Grid widget there.

var pivotGridDataSource = {
    store: {
    fields: [{

var dxPivotGridOptions = {
    dataSource: pivotGridDataSource