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. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Sending additional POST data to dataManager

Thread ID:

Created:

Updated:

Platform:

Replies:

148154 Oct 8,2019 10:31 AM UTC Jul 16,2020 01:41 PM UTC JavaScript - EJ 2 5
loading
Tags: PivotGrid
Chris Tate Davies
Asked On October 8, 2019 10:31 AM UTC

Hello there

Can I send extra POST data to the call to retrieve remote JSON data?

I have tried things like this:

var pivotData = new ej.data.DataManager({
    url: api_url + "report/data/",
    adaptor: new  ej.data.WebApiAdaptor (),
    crossDomain: true,
    type: "POST",
    postData: {"test":1}
});

However, the post data is just dropped.

In my PivotView call I use something like this:

var pivotTableObj = new ej.pivotview.PivotView({
    dataSourceSettings: {
        dataSource: pivotData,
/---

Any tips would be gratefully received.

Thanks, Chris


Chris Tate Davies
Replied On October 9, 2019 09:52 AM UTC

Don't worry about this too much. I fell back to using jquery $.post() to perform the calls.

An eventual answer might be nice so I don't need to rely on jquery forever.


Cheers

Sivamathi Natarajan [Syncfusion]
Replied On October 9, 2019 10:25 AM UTC

 
You can send data in data manager using “addParams”. Please refer the below documentation for more details about sending POST data. 
 
Code Snippet: [JavaScript] 
var remoteData = new ej.data.DataManager({ 
        url: 'https://bi.syncfusion.com/northwindservice/api/orders', 
        adaptor: new ej.data.WebApiAdaptor(), 
         crossDomain: true, 
        offline:true, 
    },new ej.data.Query().addParams('test', "4")) 
 
Meanwhile, we have prepared sample for your reference. Please find the sample in below link. 
 
Please let us know if you have any concern. 
  
Regards, 
Sivamathi Natarajan 


Stephan Schrade
Replied On July 14, 2020 09:29 AM UTC

Hi support,
I'm trying the same thig, but I have to add two parameters to the query.
I have tried
var eventData = new ej.data.DataManager({
url: "eventdata",
offline: true,
adaptor: new ej.data.UrlAdaptor
}, new ej.data.Query().addParams("eventid", "<?=$event->challengeeventid?>").addParams("<?= Yii::$app->request->csrfParam; ?>", "<?= Yii::$app->request->csrfToken; ?>"));
but this does not work. The parameters are not sent to the server.

My backend side works, because if I use
grid.query = new ej.data.Query().addParams("eventid", "<?=$event->challengeeventid?>");
grid.query.addParams("<?= Yii::$app->request->csrfParam; ?>", "<?= Yii::$app->request->csrfToken; ?>");
grid.appendTo('#Grid');
with datamanger set as
var eventData = new ej.data.DataManager({
url: "eventdata",
offline: false,
adaptor: new ej.data.UrlAdaptor
});
the grid is populated.
But this does not work with offline: true. Threrefore I tried to add the parameters directly to the datamanager.

How can I work with datamanger in offline mode and add several parameters to the query?

Regards,
Stephan



Sivamathi Natarajan [Syncfusion]
Replied On July 15, 2020 04:06 PM UTC

Hi Stephan, 
  
We are validating the requirement - "To add two parameters in offline" at our end. We will update the further details within two business days (7/17/2020). 
  
  
Regards, 
Sivamathi. 


Sivamathi Natarajan [Syncfusion]
Replied On July 16, 2020 01:41 PM UTC

 
We suspect that your requirement is to add two parameters to query and to fetch the data in offline. We have prepared a sample for your reference. Please check the below sample link. 
 
 
You can retrieve the parameters in below code. 
 
document.querySelector('.e-pivotview').ej2_instances[0].dataSourceSettings.dataSource.defaultQuery.params 
 
If still the problem exists, kindly reproduce the problem in the provided sample and revert us (or) send your sample that replicating the problem.  
 
Regards, 
Sivamathi. 


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.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon 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.Close Icon

Live Chat Icon For mobile
Live Chat Icon