Custom filtering and functionality in Pivot Client

Hi Syncfusion!
I'm working with the control "pivot client" and I want to filter the data with external parameters filled with the differents options like date range, checkbox and registers quantity, is this can be possible?:



As you can see, I already have the filters in the view, but I do not know how to send the values to the WebAPI controller.



In the view it looks like this:



Thank you for your support.
Regards.

1 Reply

MM Manikandan Murugesan Syncfusion Team November 15, 2017 01:06 PM UTC

Hi Junior, 

Thanks for contacting Syncfusion Support. 

You can send the filter values to the WebAPI controller through “doAjaxPost” method. For that, you need to create additional controller method. In the btnClick() event, you need to get date picker value and set it to the variable and you can pass it through “doAjaxPost” method to the WebAPI controller. In the “doAjaxPost”, you need to specify controller method name. Please refer below code snippet. 
Code Snippet: [javascript] 
    function btnClick(args) { 
        var data = '{ startDate : "4/9/2017" , endDate : "17/9/2017" }'; // Get value from date picker and set it to the variable 
        var pivotClientObj = $('#PivotClient1').data("ejPivotClient"); 
        var serializedCustomObject = JSON.stringify(pivotClientObj.model.customObject); 
        pivotClientObj.doAjaxPost("POST", pivotClientObj.model.url + "/" + "filterDate", JSON.stringify({ 
            "action": "initializeClient", "data": data, "customObject": serializedCustomObject, "clientParams": pivotClientObj.model.enableMeasureGroups + "-" + pivotClientObj.model.chartType + "-" + pivotClientObj.model.enableKPI 
        }), pivotClientObj._renderControlSuccess); 
    } 

You can access the data in the WebAPI controller method as like in the below screenshot. 
 

In the method, you need to filter the data using filter parameters and pass it to the GetJsonData method. 
[System.Web.Http.ActionName("filterDate")] 
[System.Web.Http.HttpPost] 
public Dictionary<string, object> filterDate(Dictionary<string, object> jsonResult) 
{ 
     return pivotClient.GetJsonData("initializeClient", ProductSales.GetSalesData(), null); 
//Here you need to pass your filtered datasource 
} 


Meanwhile, we have prepared sample as per your requirement. Please find the sample in below link. 

Thanks, 
Manikandan. 


Loader.
Up arrow icon