search envelope-o feed check
Home Unanswered Active Tags New Question
user comment-o

In Time sheet Scheduler, How Scheduler form should visible after reopening of same timesheet?

Asked by Aman Shahu
8 months ago.

I mean , I used Timesheet as component in my project . When i scheduled task it will be saved as session storage only. After reopening same timesheet scheduler ,data inside scheduler gets vanished . And i required same scheduler as data to be shown in time sheet. Data should save what we scheduled uptill we cant delete it.

Kindly help me out through above issue.

Answer posted by Dan Letecky [DayPilot]
8 months ago.

It sounds like you are using the browser's session storage to keep track of the scheduled tasks in your timesheet, and the data is vanishing when you reopen the same timesheet. The data stored in session storage is only available for the duration of the page session, and it gets wiped out once the session ends, like when you close and reopen the browser tab.

If you want the scheduled data to persist even after the session ends, you can use local storage instead of session storage. Local storage works similarly to session storage, but the data persists across browser sessions and tabs.

Here's an example of how you can modify your existing code to use local storage instead:

Saving Data to Local Storage

You can save the scheduled tasks to local storage by stringifying the data object and using localStorage.setItem:

function saveSchedulerData(data) {
  localStorage.setItem('schedulerData', JSON.stringify(data));
}

You need to save the updated data set whenever there is a change (in onEventMove, onEventResize, etc.).

Retrieving Data from Local Storage

You can retrieve the data from local storage by parsing the stringified data object using localStorage.getItem:

function loadSchedulerData() {
  const data = localStorage.getItem('schedulerData');
  return data ? JSON.parse(data) : null;
}

Deleting Data from Local Storage

If you need to remove the data at some point, you can use localStorage.removeItem:

function deleteSchedulerData() {
  localStorage.removeItem('schedulerData');
}

Applying Data to Your Timesheet Component

You can load the scheduler data when your component is mounted and apply it to the timesheet as needed. Here's an example if you're using React:

const events = loadSchedulerData();
scheduler.update({events: events});

By using local storage instead of session storage, the scheduled tasks in your timesheet should persist even after reopening the same timesheet, and you'll be able to continue working with the saved data as needed.

This question is more than 1 months old and has been closed. Please create a new question if you have anything to add.