We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
Unfortunately, activation email could not send to your email. Please try again.
Essential JS2

Syncfusion jQuery based widgets are no longer in active development. Switch to our pure JavaScript based next generation Essential JS 2 library.

Syncfusion Feedback

How to pass PivotGrid report to PivotClient dynamically?

Platform: jQuery |
Control: ejPivotClient
Tags: asp, js, mvc, pivotclient

This KB illustrates that how to pass PivotGrid report to PivotClient dynamically.

Solution:

You can pass OLAP report of PivotGrid to PivotClient dynamically through the following methods. You can work with the rendered PivotClient as usual. (like filtering, drilldown, save and load etc). 

Step 1:

Create a project for PivotGrid using any one of the below mentioned links.

JavaScript- https://help.syncfusion.com/js/pivotgrid/olap-getting-started#creating-a-simple-application-with-pivot-grid-and-olap-data-source-server-mode

ASP- https://help.syncfusion.com/aspnet/pivotclient/olap-getting-started#creating-a-simple-application-pivot-client-and-olap-data-sources-server-mode

MVC- https://help.syncfusion.com/aspnetmvc/pivotclient/olap-getting-started#creating-a-simple-application-with-pivotclient-and-olap-datasource-server-mode

Step 2:

Add a WebAPI controller (here, “OlapClientController.cs”) for PivotClient.

Step 3:

Add a button in the View page for passing Olap Report to PivotClient to render the same on button click. Please refer the below code snippet for View page.

JS

<div class="cols-sample-area" style=" width:100%;height:100%; position:absolute">
<button class="btn">Load PivotClient</button>
<div id="PivotGrid" style="width: 100%"></div>
<div id="PivotClient"></div>

 

MVC

<button class="btn">Load PivotClient</button>
@Html.EJ().Pivot().PivotGrid("PivotGrid").Url(Url.Content("~/api/OlapGrid"))
<div id="PivotClient"></div>

 

ASP

<button class="btn">Load PivotClient</button>
ej:PivotGrid ID="PivotGrid" runat="server" Locale="en-US" Url="../api/OlapGrid">
</ej:PivotGrid>
<div id="PivotClient"></div>

 

JS (Click event for all the platforms)

<script type="text/javascript">
 
  $(".btn").ejButton({click: "Apply"});
    $(function () {
       $("#PivotGrid").ejPivotGrid({ url: "OlapGrid", enableGroupingBar: true});
  });
 
  function Apply() {
    $(".e-pivotclient").remove();
    var gridPanel = ej.buildTag("div#PivotClient", "", {})[0].outerHTML;
    $(gridPanel).appendTo(".cols-sample-area");
    var controlObj= $("#PivotGrid").data("ejPivotGrid");
    var customObj = JSON.parse(controlObj.getOlapReport()).Report;
    $("#PivotClient").ejPivotClient({
           url: "OlapClient",
           customObject: { Report: customObj 
    });
  }                   
   
 

 

Step 4:

In “OlapClientController.cs”, we need to pass the report with “SetCurrentReport” method in the “InitializeClient” method.

[System.Web.Http.ActionName("InitializeClient")]
[System.Web.Http.HttpPost]
public Dictionary<string, object> InitializeClient(Dictionary<string, object> jsonResult)
 {
  OlapDataManager DataManager = null;
  dynamic customData = serializer.Deserialize<dynamic>(jsonResult["customObject"].ToString());
 
  //…
  DataManager.SetCurrentReport(OLAPUTILS.Utils.DeserializeOlapReport(customData["Report"]));
  //…
  return report;
 }     

 

ADD COMMENT
You must log in to leave a comment

Please sign in to access our KB

This page will automatically be redirected to the sign-in page in 10 seconds.

Up arrow icon

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile