How do we force reload/refresh resources in a scheduler? _schedule.RefreshEventsAsync() does not refresh resource data. Is there a _scheduleResource.RefreshDataAsync()?
<SfSchedule @ref="_schedule">
<ScheduleResources>
<ScheduleResource @ref="_scheduleResource" TItem="Room" TValue="int?" Field="RoomId" Title="Room" Name="Rooms" TextField="Text" IdField="Id" AllowMultiple="false">
<SfDataManager Url="/api/Room" Adaptor="Adaptors.UrlAdaptor"></SfDataManager>
</ScheduleResource>
</ScheduleResources>
</SfSchedule>
Hi Patrick,
We have checked on your requirement and suggest you to call StateHasChanged() method once the resources have loaded in the scheduler in order to refresh the resources. Kindly try the solution and if the issue persists, then you can force reload the scheduler on a button click using the uriHelper class like the below code.
|
uriHelper.NavigateTo(uriHelper.Uri, forceLoad: true); |
Regards,
Ruksar Moosa Sait
Hi Ruksar,
I confirmed that calling StateHasChanged() does not refresh the resources.
I have other controls on the same page (e.g. textbox, pager, dialog, etc) that I would like to keep their state. Calling uriHelper.NavigateTo(uriHelper.Uri, forceLoad: true); reloads the page and forces other controls to loss their state. Please advice.
Regards,
Patrick
Hi Patrick,
We have checked on your query and let you know that we do not have direct options like RefreshEventAsync to refresh the resource data. Hence we suggest you trigger the RemoveResource public method by passing null parameters to it on a button click to refresh only the Scheduler Resources after it is loaded in the scheduler. We have prepared a sample for your reference. Kindly try the attached sample and let us know if this meets your requirement
[ResourceAdaptopMultiLevel.razor]
|
public void OnClick() { ScheduleRef.RemoveResource<ResourceData>(null, null); } |
Regards,
Ruksar Moosa Sait
Dear Ruksar,
I refer to your sample on multiadaptor. I have made some modification to ResourceList and LastResourceList. On button click, how do I make scheduler reflect the correct text? e.g. DateTime.Now.TimeOfDay.
Hi Patrick,
We have checked on your query and suggest you to bind @Key value to the scheduler to increment it on a button click and define the ResourceData in the ReadAsync method like the below code to achieve your requirement.
|
<SfSchedule @ref="ScheduleRef" @key="ScheduleKey" TValue="EventData" Width="100%" Height="650px" @bind-CurrentView="CurrentView" @bind-SelectedDate="CurrentDate"> |
|
public int ScheduleKey = 1; public void OnClick() { ScheduleKey = ScheduleKey + 1; } public class CustomAdaptor : DataAdaptor { public async override Task<object> ReadAsync(DataManagerRequest dataManagerRequest, string key = null) { await Task.Delay(100); //To mimic asynchronous operation, we delayed this operation using Task.Delay List<ResourceData> EventData = ResourceList(); return dataManagerRequest.RequiresCounts ? new DataResult() { Result = EventData, Count = EventData.Count() } : (object)EventData; } } public class CustomAdaptor1 : DataAdaptor { public async override Task<object> ReadAsync(DataManagerRequest dataManagerRequest, string key = null) { await Task.Delay(100); //To mimic asynchronous operation, we delayed this operation using Task.Delay List<LastLevel> EventData = LastResourceList(); return dataManagerRequest.RequiresCounts ? new DataResult() { Result = EventData, Count = EventData.Count() } : (object)EventData; } } |
Output:
Kindly try the attached sample and let us know if this meets your requirement.
Regards,
Ruksar Moosa Sait
Hi Ruksar,
Yes, this meet my requirement. Thank you for your support.
Regards,
Patrick
Thanks for your update.
We are happy to hear that our solution fulfilled your requirement.
Please get back to us if you need any further assistance.
Regards,
Vinitha
Hi, changing the key is just a workaround, in other words a "makeshift"
Please create a feature request so we have an UpdateResourcesAsync just like we have it for Events
Hi Daniel,
We have reviewed your query and would like to clarify that the Schedule component manages resource layout independently from event rendering. This means that refreshing events asynchronously does not automatically refresh the resources. If you want to refresh the resources, you need to update the resource data source directly.
Don't hesitate to get in touch if you require further help or more information.
Regards,
Vijay