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.
Unfortunately, activation email could not send to your email. Please try again.

How do your refresh / reload a pivot grid (data only) by using jquery / ajax

Thread ID:

Created:

Updated:

Platform:

Replies:

131230 Jun 29,2017 09:25 AM Jul 3,2017 01:46 AM ASP.NET MVC 4
loading
Tags: PivotGrid
John
Asked On June 29, 2017 09:25 AM

My Pivot Grid works fine on initial load - JSON, but I'm having trouble finding a way to reload the data or update the data source. I'm using MVC, not the SF JavaScript version.  I'm a little lost on what client side method are available to achieve this.


Thanks


Sastha Prathap Selvamoorthy [Syncfusion]
Replied On June 30, 2017 03:30 AM

Hi John, 
 
Thanks for contacting Syncfusion Support. 
 
refreshPivotGrid” method is available to refresh the PivotGrid with new updated data. We have provided a sample code to refresh the PivotGrid using button click event. Please find the code snippet for your reference below. 
 
Sample Code: 
@Html.EJ().Pivot().PivotGrid("PivotGrid1").ClientSideEvents(clientSideEvents => clientSideEvents.Load("onLoad")).DataSource(dataSource => dataSource.Rows(rows => { rows.FieldName("Country").FieldCaption("Country").Add(); }).Columns(columns => { columns.FieldName("Product").FieldCaption("Product").Add(); }).Values(values => { values.FieldName("Amount").Add(); })) 
 
@Html.EJ().Button("Button1").Size(ButtonSize.Normal).Text("Click").ClientSideEvents(events => events.Click("btnClick")) 
 
<script>  
    function btnClick(args) {  
              var pivotGridObj = $('#PivotGrid1').data("ejPivotGrid"); 
        $.ajax({  
            type: "POST",  
            url: "../GetData",  // specify the url to get JSON data 
            contentType: 'application/json; charset=utf-8',  
            dataType: 'json',  
            success: function (val) {  
               pivotGridObj.model.dataSource.data = JSON.parse(val); // you can set the JSON data here 
               pivotGridObj.refreshPivotGrid(); // method call to refresh the PivotGrid 
            },  
        });  
    }  
</script>  
 
Please let us know, if you need any further assistance. 
 
Regards, 
Sastha Prathap S.

John
Replied On June 30, 2017 05:06 PM

Thank you for the solution .... I was also trying refresh a pivot chart , I see refreshPivotChart isn't a method for that object, do you know the correct method for refreshing a pivot chart?

Thanks again.




John
Replied On June 30, 2017 05:12 PM

Figured it out by logging the methods to the console.

console.log(pivot);
   pivot.refreshControl();


thanks


Sastha Prathap Selvamoorthy [Syncfusion]
Replied On July 3, 2017 01:46 AM

Hi John, 
 
Thanks for the response. 
 
Please let us know, if you need any further assistance. 
 
Regards, 
Sastha Prathap S. 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

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.

;