ASP.NET MVC Controls > Controls > OLAP > Features > Data Binding > Cube Data using SSAS |
This section describes the steps required to add cube data in the OLAP control using SSAS (SQL Server Analysis Services). In the example below, the PivotEngine component binds to a service. In this the DataEngine Web Api is supported, the data engine is responsible for data aggregation in this example. The PivotPanel control and PivotGrid control binds the PivotEngine. You can change the view definition in the PivotPanel control. The aggregated data will be obtained from the service. Then the PivotGrid control displays the aggregated data.
This topic comprises of the following steps:
Create an ASP.NET MVC Application using Visual Studio template to enable WebAPI configuration.
Install the DataEngine Web API and C1.WebApi packages from the NuGet server.
C1.WebApi.dll
C1.WebApi.DataEngine.dll
C1.DataEngine.4.dll
System.Net.Http.Formatting.dll
System.Web.Http.dll
System.Web.Http.Owin.dll
System.Web.Http.WebHost.dll
After adding the required references, you need to configure the Startup.cs
to fetch the data that is stored on SSAS server.
using C1.DataEngine; using Microsoft.Owin; using Owin; using System.IO; using System.Linq; using System.Web.Http; using OlapSSAS.Models; [assembly: OwinStartupAttribute(typeof(OlapSSAS.Startup))] namespace OlapSSAS { public partial class Startup { private readonly HttpConfiguration config = GlobalConfiguration.Configuration; public void Configuration(IAppBuilder app) { app.UseDataEngineProviders() .AddCube("cube", @"Data Source=http://ssrs.componentone.com/OLAP/msmdpump.dll; Provider=msolap;Initial Catalog=AdventureWorksDW2012Multidimensional", "Adventure Works"); } } }
Create a Controller and View for OLAP control and follow the below steps to initialize an OLAP control.
Add a new Controller
OlapController
).// GET: SSAS public ActionResult Index() { return View(); }
OlapController.
Index()
.@using C1.Web.Mvc.Olap; @using C1.Web.Mvc.Grid @Html.C1().Styles() @Html.C1().Scripts().Basic().Olap() @(Html.C1().PivotEngine().Id("ssasEngine") .BindService("~/api/dataengine/cube") .Fields(pfcb => pfcb.Items(c => c.AddCubeField(fb => fb.Header("Internet Orders").DimensionType(DimensionType.Folder).SubFields(sfsb => sfsb.Add(sfb => sfb.Header("Internet Order Count").Binding("[Measures].[Internet Order Count]").DataType(DataType.Number)))) .AddCubeField(fb => fb.Header("Product").SubFields(sfsb => sfsb.Add(sfb => sfb.Header("Category").Binding("[Product].[Category]").DataType(DataType.String)) .Add(sfb => sfb.Header("Stocking").SubFields(sfs => sfs.Add(f => f.Binding("[Product].[Color]").Header("Color").DataType(DataType.String)) .Add(f => f.Binding("[Product].[Class]").Header("Class").DataType(DataType.String)))) .Add(sfb => sfb.Header("Product").Binding("[Product].[Product]").DataType(DataType.String)) )))) .RowFields(rfb => rfb.Items("[Product].[Product]")) .ValueFields(vfb => vfb.Items("[Measures].[Internet Order Count]")) ) @Html.C1().PivotPanel().ItemsSourceId("ssasEngine") @Html.C1().PivotGrid().ItemsSourceId("ssasEngine")
Razor |
Copy Code
|
---|---|
@using C1.Web.Mvc.Grid <c1-pivot-engine id="ssasEngine" service-url="~/api/dataengine/cube"> <c1-pivot-field-collection> <c1-pivot-field header="Internet Orders"> <c1-pivot-field binding="[Measures].[Internet Order Count]" header="Internet Order Count" type="DataType.Number"></c1-pivot-field> </c1-pivot-field> <c1-pivot-field header="Product"> <c1-pivot-field binding="[Product].[Category]" header="Category" type="DataType.String"></c1-pivot-field> <c1-pivot-field header="Stocking"> <c1-pivot-field binding="[Product].[Color]" header="Color" type="DataType.String"></c1-pivot-field> <c1-pivot-field binding="[Product].[Class]" header="Class" type="DataType.String"></c1-pivot-field> </c1-pivot-field> <c1-pivot-field binding="[Product].[Product]" header="Product" type="DataType.String"></c1-pivot-field> </c1-pivot-field> </c1-pivot-field-collection> <c1-view-field-collection c1-property="RowFields" items="[Product].[Product]"></c1-view-field-collection> <c1-view-field-collection c1-property="ValueFields" items="[Measures].[Internet Order Count]"></c1-view-field-collection> </c1-pivot-engine> |
Append the folder name and view name to the generated URL (for example: http://localhost:1234/Olap/Index) in the address bar of the browser to see the view. |
The following image shows how OLAP control appears in the browser after completing the above steps: