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.