OLAP control allows you to access and update field properties at runtime using the object model. You can auto generate the fields and set the properties of value fields at the client side.
This topic helps you to understand, how to access and update field properties in an OLAP control at client side. The following image shows how OLAP control appears after updating field properties at runtime using the JavaScript code.
If you want to auto-generate the fields and set/update the properties of value fields at runtime, use the following example code to define pivot fields in OLAP control. The example uses ProductData.cs model added in the Quick Start: Add Data to OLAP topic.
Razor |
Copy Code
|
---|---|
@using <ApplicationName>.Models; @model IEnumerable<ProductData> <script type="text/javascript"> c1.documentReady(function () { var engine = c1.getService('indexEngine'); var field = engine.fields.getField("Sales"); field.aggregate = wijmo.Aggregate.Avg; field.format = "n2"; }) </script> @(Html.C1().PivotEngine().Id("indexEngine").Bind(Model) .RowFields(pfcb => pfcb.Items("Country")) .ColumnFields(cfcb => cfcb.Items("Product")) .ValueFields(vfcb => vfcb.Items("Sales"))) @(Html.C1().PivotGrid().ItemsSourceId("indexEngine"))s |