How to persist the current view of schedule manually in JavaScript application?
This knowledge base explains how to implement persistence manually from the application end. For example, current view of JavaScript Scheduler is considered in this section.
Current View - Persistence
Step 1: Bind the actionComplete event to store the scheduler’s current view into the local storage as shown in the following code example.
actionComplete: function (args) { if (args.requestType == "viewNavigate") { // Store the display name in local storage when navigating the views window.localStorage.view = this.activeViewOptions.displayName; } }
actionComplete: https://ej2.syncfusion.com/javascript/documentation/api/schedule/#actioncomplete
Step 2: Bind the created event to retrieve the current view after the page reloads from local storage as shown in the following code example.
created: function () { var len = this.views.length; // Set the last active view when page is reloading for (var i = 0; i < len; i++) { if (window.localStorage.view === this.views[i].displayName) { this.views[i].isSelected = true; } else { this.views[i].isSelected = false; } } this.refresh(); },
Created: https://ej2.syncfusion.com/javascript/documentation/api/schedule/#created
Step 3: Run the sample. Change the current view of scheduler and reload the page to ensure whether the code works as expected.
Refer to the example from the following GitHub link.
Example –https://github.com/SyncfusionExamples/ej2-javascript-scheduler-retain-currentview
Conclusion
I hope you enjoyed learning about how to persist the current view of schedule manually in JavaScript application.
You can refer to our JS Sceduler feature tour page to know about its other groundbreaking feature representations and documentation, and how to quickly get started for configuration specifications. You can also explore our JavaScript Scheduler example to understand how to create and manipulate data.
For current customers, you can check out our components from the License and Downloads page. If you are new to Syncfusion, you can try our 30-day free trial to check out our other controls.
If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forums, Direct-Trac, or feedback portal. We are always happy to assist you!