Call to handler to send the datasource to PIVOT TABLE

I would like use the same tecnic that the grid to call a handler to send the datasource, but It´s not working on PiVOT TABLE. I don´t know how to insert the "XSRF-TOKEN"
How I can do that on Pivot Table?
My Example.
HTML
________________________________________________
@Html.AntiForgeryToken()
JAVASCRIPT
____________________________________________________________
CODE
_________________________________
public IActionResult OnGetPivotDataJson()
{
List pivotData = new List();
pivotData.Add(new PivotData { Sold = 31, Amount = 52824, Country = "France", Products = "Mountain Bikes", Year = "FY 2015", Quarter = "Q1" });
pivotData.Add(new PivotData { Sold = 51, Amount = 86904, Country = "France", Products = "Mountain Bikes", Year = "FY 2015", Quarter = "Q2" });
pivotData.Add(new PivotData { Sold = 90, Amount = 153360, Country = "France", Products = "Mountain Bikes", Year = "FY 2015", Quarter = "Q3" });
pivotData.Add(new PivotData { Sold = 25, Amount = 42600, Country = "France", Products = "Mountain Bikes", Year = "FY 2015", Quarter = "Q4" });
pivotData.Add(new PivotData { Sold = 27, Amount = 46008, Country = "France", Products = "Mountain Bikes", Year = "FY 2016", Quarter = "Q1" });
string output = JsonConvert.SerializeObject(pivotData);
return new JsonResult(pivotData);
}
Thanks.

2 Replies

RV Rubén Valentín April 8, 2020 01:15 PM UTC

The solution: 

 function onLoad() {
        
            this.dataSourceSettings.dataSource.beforeSend = function (xhr) {
                xhr.setRequestHeader("XSRF-TOKEN", $('input:hidden[name="__RequestVerificationToken"]').val());
            };
        }


SN Sivamathi Natarajan Syncfusion Team April 9, 2020 02:09 PM UTC

 
Thanks for contacting Syncfusion support. 
 
Based on your requirement we have prepared a sample to insert the “XSRF-TOKEN" to pivot table in load method. Kindly check the below sample link for your reference. 
 
function onLoad() { 
 var dataManager = this.dataSourceSettings.dataSource; 
        dataManager.dataSource.headers = [{ 'XSRF-TOKEN': $("input:hidden[name='__RequestVerificationToken']").val() }]; 
    } 
 
 
We hope the above sample meets your requirements. 
 
Regards, 
Sivamathi. 


Loader.
Up arrow icon