- Home
- Forum
- ASP.NET Core - EJ 2
- Call to handler to send the datasource to PIVOT TABLE
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
____________________________________________________________
function onLoad() {
console.log(this);
/*this.dataSource.dataSource.headers = [{ 'XSRF-TOKEN': $("input:hidden[name='__RequestVerificationToken']").val() }]*/; This is a TRY
//this.dataSourceSettings.dataSource.adaptor.addParams = [{ 'XSRF-TOKEN': $("input:hidden[name='__RequestVerificationToken']").val() }]; This is a TRY
}
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.
SIGN IN To post a reply.
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() }];
} |
Sample Link: https://www.syncfusion.com/downloads/support/directtrac/general/ze/Grid_razor_2.2-654820334
We hope the above sample meets your requirements.
Regards,
Sivamathi.
SIGN IN To post a reply.
- 2 Replies
- 2 Participants
-
RV Rubén Valentín
- Apr 8, 2020 12:36 PM UTC
- Apr 9, 2020 02:09 PM UTC