How to prevent a DataManager object from sending a request containing a "$batch" variable after dragStop() event is triggered?

Hello, I would like to know if there's a way to prevent a DataManager object from sending a request containing a "$batch" variable after the event dragStop() is triggered on the Schedule.
I've set up my DataManager object with the following properties:
url: custom_url
adaptor: ODataV4Adaptor
crossDomain: true

Whenever a user triggers the dragStop() event, two requests to the custom_url are sent

One request is the one I've set it up on the dragStop() event
And the second one is a request containing a variable "$batch" and header data containing the event I just dragged
I want to know if there's a way to prevent the second request from happening since it's being blocked by CloudFlare software and I don't really need it.


3 Replies 1 reply marked as answer

SK Satheesh Kumar Balasubramanian Syncfusion Team December 22, 2023 02:25 PM UTC

Hi Derick,

We have validated your reported query at our end. You can resolve the reported problem by using the below way. In the below code example, we have used a CustomAdaptor and overridden the default OdataV4Adaptor batchRequest method instead of sending your request in the dragStop event.


Kindly refer to the below code example and documentation link for more information.


UG: https://ej2.syncfusion.com/javascript/documentation/schedule/data-binding#using-custom-adaptor


index.js

export class CustomAdaptor extends ej.data.ODataV4Adaptor {

  batchRequest(dm, changes, e) {
    var result = ODataV4Adaptor.prototype.batchRequest.call(
      this,
      dm,
      changes,
      e
    );
    result.url = dm.dataSource.batchUrl + this.options.batch;
    return result;
  }
}

var dataManager = new ej.data.DataManager({
  url: 'http://localhost:25255/odata',
  batchUrl: `http://localhost:25255/odata/`,
  adaptor: new CustomAdaptor(),
  crossDomain: true,
});
var scheduleObj = new ej.schedule.Schedule({
  height: '650px',
  selectedDate: new Date(2018, 9, 4),
  eventSettings: {
    dataSource: dataManager,
    query: new ej.data.Query().from('EventDatas'),
  },
});
scheduleObj.appendTo('#Schedule');

Regards,
Satheesh

Marked as answer

DM Derick Milanez da Silva replied to Satheesh Kumar Balasubramanian December 22, 2023 02:42 PM UTC

Thank you very much!



SK Satheesh Kumar Balasubramanian Syncfusion Team December 26, 2023 09:33 AM UTC

You're welcome! Don't hesitate to reach out if you have any more questions or need further assistance


Loader.
Up arrow icon