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. Image for the cookie policy date

Sending additional POST data to dataManager

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


5 Replies

CT Chris Tate Davies 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


SN Sivamathi Natarajan Syncfusion Team 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 



SS Stephan Schrade 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




SN Sivamathi Natarajan Syncfusion Team 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. 



SN Sivamathi Natarajan Syncfusion Team 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. 


Loader.
Live Chat Icon For mobile
Up arrow icon