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

Offline events on network loss

Thread ID:

Created:

Updated:

Platform:

Replies:

144049 Apr 16,2019 07:58 AM UTC Apr 17,2019 12:54 PM UTC Angular - EJ 2 1
loading
Tags: Schedule
Eloy
Asked On April 16, 2019 07:58 AM UTC

Hi, 

I'm implementing the scheduler as a personal event reminder, I want to use it in a Angular Application working offline some time, I wondered using Angular services, and observables in order to retrieve events, and making the CRUD, because I can control the request and response in case of loss of internet connectivity and return the localStorage data if any.

Can you help me?

I'm trying to override a DataAdaptor, catching the processResponse method, but this method it's only called when the response was successful, how can I return a fixed response if the request fails?

I tried overriding beforeSend, and creating anonymous function in request.onerror, I catch the error, but I don't know how to return the event data to the control.

class CustomAdaptor extends WebApiAdaptor {
processResponse(data: DataResult, ds?: DataOptions, query?: Query, xhr?: XMLHttpRequest, request?: Ajax, changes?: CrudOptions): Object {
//debugger;
console.log("--ProcessResponse--");
console.log(data);
return super.processResponse(data, ds, query, xhr, request, changes);
}

beforeSend(dm: DataManager, request: XMLHttpRequest, settings: Ajax)
{
request.onerror = function () {
//debugger;
console.log("--Error Request--");
//Here i want to return event data to the Adaptor --> Scheduler event
let localData = [{Id:1, Subject: "Subject 1", StartTime: new Date(), EndTime: new Date()}]


}
console.log("--beforeSend--");
super.beforeSend(dm, request, settings);
}
}

Nevitha Ravi [Syncfusion]
Replied On April 17, 2019 12:54 PM UTC

Hi Eloy, 

Greetings from Syncfusion Support. 

We suspect that your requirement is to assign stored data on network failure and this can be achieved in actionFailure event of scheduler. In the following sample, we have stored the scheduler events in localStorage using dataBinding event. 

  public onDataBinding(e: { [key: string]: Object }): void { 
    localStorage.setItem("scheduleData", JSON.stringify(e.result)); 
  } 
  public onActionFailure(): void { 
    this.scheduleObj.eventSettings.dataSource = JSON.parse(localStorage.getItem("scheduleData")); 
  } 


Please check whether the solution meets your requirement else share your purpose of achieving the scenario using customAdaptor. 

Regards, 
Nevitha 


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