Complete the following steps to add data to OLAP control:
The following image shows how OLAP control appears in the browser after completing the above steps:
Step 1: Create an MVC Application
Create a new MVC application using the ComponentOne or VisualStudio templates. For more information about creating an MVC application, see Configuring your MVC Application topic.
Step 2: Create a Datasource for OLAP
Create a new class inside the Models folder to create a data source for the OLAP control.
- Add a new class to the folder Models (for example:
ProductData.cs
). For more information about how to add a new model, see Adding controls.
- Add the following code to the model to define the data for OLAP.
Back to Top
Step 3: Add an OLAP control
Create a Controller and View for OLAP control and follow the below steps to initialize an OLAP control.
Add a new Controller
- In the Solution Explorer, right click the folder Controllers.
- From the context menu, select Add | Controller. The Add Scaffold dialog appears.
- Complete the following steps in the Add Scaffold dialog:
- Select Empty MVC Controller template.
- Set name of the controller (for example:
OlapController
).
- Click Add.
- Replace the method Index() with the following method.
Add a View for the Controller
- From the Solution Explorer, expand the folder Controllers and double click the
OlapController.
- Place the cursor inside the method
Index()
.
- Right click and select Add View. The Add View dialog appears.
- In the Add View dialog, verify that the view name is Index and View engine is Razor (CSHTML).
- Click Add to add a view is for the controller. Copy the following code and paste it inside Index.cshtml.
Step 4: Build and Run the Project
- Click Build | Build Solution to build the project.
- Press F5 to run the project.
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.
Back to Top
See Also