Log In
Home
Support
Demos
Documentation
Blogs
Training
Webinars
[Expand]General Information
[Expand]WinForms Controls
[Collapse]ASP.NET Controls and MVC Extensions
 [Expand]Prerequisites
 [Expand]What's Installed
 [Expand]Common Concepts
 [Expand]ASP.NET WebForms Controls
 [Collapse]ASP.NET MVC Extensions
  [Expand]Product Information
  [Expand]Getting Started
  [Expand]Common Concepts
  [Expand]Grid View
  [Expand]Card View
  [Expand]Vertical Grid
  [Expand]Spreadsheet
  [Expand]Rich Text Editor
  [Expand]HTML Editor
  [Expand]Image and Data Browsing
  [Expand]Docking and Popups
  [Expand]Navigation and Layout Extensions
  [Expand]File Management
  [Expand]Multi-Use Site Extensions
  [Expand]Charts
  [Collapse]Pivot Grid
   [Collapse]Getting Started
     Lesson 1 - Bind a Pivot Grid to an MDB Database
     Lesson 2 - Bind a Pivot Grid to an OLAP Data Source
     Tutorial Videos
    Integrate the PivotGrid Extension into a Project
   [Expand]Binding to Data
    Main Features - PivotGrid
    Client-Side Functionality
   [Expand]UI Elements
  [Expand]Scheduler
  [Expand]Tree List
  [Expand]Data Editor Extensions
  [Expand]Report Extensions
  [Expand]SpellChecker
 [Expand]Localization
 [Expand]Redistribution and Deployment
  Get More Help
 [Expand]API Reference
[Expand]ASP.NET Bootstrap Controls
[Expand]WPF Controls
[Expand]Xamarin Controls
[Expand]Windows 10 App Controls
[Expand]Document Server
[Expand]Reporting
[Expand]Report Server
[Expand]Dashboard
[Expand]eXpressApp Framework
[Expand]CodeRush
[Expand]Cross-Platform Core Libraries
[Expand]Tools and Utilities
 End-User Documentation

Lesson 2 - Bind a Pivot Grid to an OLAP Data Source

This topic describes how to connect the PivotGrid extension to an OLAP data source - an Analysis Services server or a local cube file.

To bind the PivotGrid to an OLAP data source, follow the steps below.

Expanded Step 1. Create an ASP.NET MVC Application

  1. To learn how to create an ASP.NET MVC Application, see steps 1-6 from Lesson 1 - Bind a Pivot Grid to an MDB Database.

    Note

    You can add the PivotGrid extension manually. To learn more, see Integration into the Project.

Expanded Step 2-3. Add the PivotGrid Extension to the MVC Application

  1. Add the PivotGrid extension to your project using the Insert DevExpress MVC Extension Wizard. For this, open a required View file (Views | Home | Index.cshtml in this topic), right-click the desired location to display the menu, and click Insert DevExpress MVC Extension...

  2. In the invoked dialog, go to the Data tab, select PivotGrid and click Insert. The wizard automatically generates the View code for the extension and inserts it into the View at the cursor position.

Expanded Step 4. Create a Connection String

  1. In the project, create the Helpers folder, right-click it and add a new PivotGridOLAPHelper.cs helper class that will provide access to the connection string.

    Specify an OLAP connection string in this class by creating a new OLAPConnectionString public static property.

    In this tutorial, the following string is used to connect to OLAP.

    "Data Source=https://demos.devexpress.com/Services/OLAP/msmdpump.dll;Initial Catalog=Adventure Works DW Standard Edition;Cube Name=Adventure Works;"

    The code snippet below demonstrates the created helper class.

Expanded Step 5-6. Change the View Code

  1. In the pivot grid's generated View code (Views | Home | _PivotGridPartial.cshtml), use the PivotGridExtension.BindToOLAP method with the specified OLAP connection string from the PivotGridOLAPHelper class. This enables binding to an OLAP data source. After that, add and configure pivot grid fields.

    The table below illustrates the PivotGrid fields and their settings.

    PivotGridFieldBase.FieldName

    PivotGridFieldBase.Area

    PivotGridFieldBase.AreaIndex

    [Ship Date].[Calendar Year].[Calendar Year] PivotArea.RowArea 0
    [Customer].[City].[City] PivotArea.ColumnArea 0
    [Sales Territory].[Sales Territory].[Country] PivotArea.FilterArea 0
    [Measures].[Order Count] PivotArea.DataArea 0

    After these manipulations, your Partial View code (_PivotGridPartial.cshtml) will look as follows.

  2. Run the project. As a result, you have a fully functional MVC PivotGrid bound to an OLAP cube.

How would you rate this topic?​​​​​​​