Data Disappears When Switching Between Views in Freedom UI Custom Page
Hello Community,
I’ve built a custom page in Freedom UI to display my data in both List View and Calendar View. I implemented the logic in `SCHEMA_HANDLERS` and used `crt.LoadDataRequest` to toggle between the views. The logic works fine when switching to Calendar View for the first time.
Issue:
1] When switching from Calendar View to List View and then back to Calendar View, the data disappears.
I have to refresh the page to make the data reappear in the Calendar.
Regards,
Ajay Kuthe
Like
Hello,
Please describe in detail how exactly this was implemented and provide screenshots of this button's settings.
Mira Dmitruk,
I used the 'Refresh data' action to trigger the 'crt.LoadDataRequest' and control the visibility of elements to switch between views (Calender and List).
#Code Logic in Handler
handlers: /**SCHEMA_HANDLERS*/[{
request: "crt.LoadDataRequest",
handler: async (request, next) => {
// Check if the data source name is "ListOrCalenderView"
if (request.dataSourceName === "ListOrCalenderView") {
// Retrieve the current view mode (Calendar or List)
const IsCalenderView = await request.$context.IsCalenderView;
// If the current view is not Calendar (i.e., it's List View)
if (IsCalenderView === false) {
// Set the Button caption to "List View"
request.$context.ListOrCalenderView_caption = "List View";
request.$context.IsCalenderView = true;
// Set the ListView flag to false since we are now in Calendar view
request.$context.IsListView = false;
} else {
// If the current view is Calendar, switch to List View
request.$context.ListOrCalenderView_caption = "Calender View"; request.$context.IsCalenderView = false;
request.$context.IsListView = true;
}
}
Regards,
Ajay K