PivotGridDataSource

An object that provides access to data for the dxPivotGrid widget.

Type:

Object

The PivotGridDataSource object is a connection between a dxPivotGrid widget and the data provided by a web service or data stored locally. The DataSource underlying data access logic is isolated in a Store. You can use the following Store types in the PivotGridDataSource.

  • ArrayStore
    Provides access to an in-memory array.

  • XmlaStore
    Provides access to a remote OLAP service.

  • LocalStore
    Provides access to an HTML5 web storage.

  • ODataStore
    Provides access to a remote OData service.

  • CustomStore
    A Store that enables you to implement your own data access logic.

To create a PivotGridDataSource instance, call its constructor and pass the configuration object to it.

JavaScript
var myDataSource = new DevExpress.data.PivotGridDataSource(pivotGridDataSourceConfig);

The core field of the configuration object is store. If your Store type is XmlaStore, no additional configuration is required, whereas if you use other Store types, you also need to describe your data for dxPivotGrid by assigning the list of fields to the fields array.

To associate a PivotGridDataSource instance with the widget, pass this instance to the dataSource option of the widget.

HTML
<div data-bind="dxPivotGrid: { dataSource: myDataSource }"></div>

You can also pass the PivotGridDataSource configuration object to the dataSource option. In this case, the PivotGridDataSource instance will be automatically created within the widget.

HTML
<div data-bind="dxPivotGrid: { dataSource: pivotGridDataSourceConfig }"></div>
NOTE
If you create a PivotGridDataSource instance outside the widget, be sure to dispose of it when it is no longer used. If the PivotGridDataSource is created within the widget, it will be disposed of automatically.

Refer to the DataSource and Data Layer topics for more information about working with data in DevExtreme.

Configuration

This section describes the configuration options of the PivotGridDataSource object.

Name Description
fields

An array of pivot grid fields.

filter

Specifies data filtering conditions.

localSorting

Indicates whether or not the local sorting of the XMLA data should be performed.

onChanged

A handler for the changed event.

onFieldsPrepared

A handler for the fieldsPrepared event.

onLoadError

A handler for the loadError event.

onLoadingChanged

A handler for the loadingChanged event.

retrieveFields

Indicates whether or not the automatic field generation from data in the Store is enabled.

store

Specifies the underlying Store instance used to access data.

NOTE
To create a PivotGridDataSource instance that uses custom data access logic, pass the CustomStore configuration object to the PivotGridDataSource constructor as shown below.
JavaScript
var myPivotGridDataSource = new DevExpress.data.PivotGridDataSource({
    load: function(loadOptions) {
        // data loading logic
    },
    byKey: function(key) {
        // data access by key logic
    }
});

Methods

This section describes the methods used to manipulate the PivotGridDataSource object.

Name Description
collapseAll(id)

Collapses all header items of a field.

collapseHeaderItem(area, path)

Collapses a specified header item.

dispose()

Disposes of all resources associated with this PivotGridDataSource.

expandAll(id)

Expands all header items of a field.

expandHeaderItem(area, path)

Expands a specified header item.

field(id)

Gets current options of a specified field.

field(id, options)

Sets one or more options of a specified field.

fields()

Gets all fields from the data source.

fields(fields)

Sets the fields option.

getAreaFields(area, collectGroups)

Gets all fields within a specified area.

getData()

Gets data displayed in a PivotGrid.

isLoading()

Indicates whether or not the PivotGridDataSource is currently being loaded.

load()

Starts loading data.

off(eventName)

Detaches all event handlers from the specified event.

off(eventName, eventHandler)

Detaches a particular event handler from the specified event.

on(eventName, eventHandler)

Subscribes to a specified event.

on(events)

Subscribes to the specified events.

Events

This section describes events raised by the PivotGridDataSource object.

Name Description
changed

Fires after data is successfully loaded or reloaded.

fieldsPrepared

Fires after all fields are prepared.

loadError

Fires when data loading is failed.

loadingChanged

Fires when the data loading status is changed.

To handle events, use one of the following methods.