Hello,
I'm trying to make a button that shows/hides appointments with a specific boolean property setted to true from the scheduler.
This is what I tried:
private async Task ShowDone(bool show)
{
if (show)
{
// Show hidden appointments
ViewModel.Appointments = ViewModel.Appointments.Concat(ViewModel.EventsDone).ToList();
ViewModel.EventsDone.Clear();
_schedule.Refresh();
}
else
{
// Hide appointments
ViewModel.EventsDone = ViewModel.Appointments.Where(x => x.IsDone).ToList();
ViewModel.Appointments = ViewModel.Appointments.Except(ViewModel.EventsDone).ToList();
_schedule.Refresh();
}
}
Where ViewModel.Appointments is the list setted as source of the scheduler, on click it should remove/hide events with IsDone==true and show them when clicked again, the appointment model is the following:
public class AppointmentModel
{
public int Id { get; set; }
public string Subject { get; set; }
public string Location { get; set; }
public DateTime StartTime { get; set; }
public DateTime EndTime { get; set; }
public string Description { get; set; }
public bool IsDone { get; set; }
public virtual string ElementType { get; set; }
}
This sometimes works and sometimes no, I can't understand why, and sometimes throws the following exception (but blazor still works):
System.Threading.Tasks.TaskCanceledException: A task was canceled.
at Microsoft.JSInterop.JSRuntime.InvokeWithDefaultCancellation[T](String identifier, Object[] args)
at Microsoft.JSInterop.JSRuntimeExtensions.InvokeVoidAsync(IJSRuntime jsRuntime, String identifier, Object[] args)
at Syncfusion.Blazor.SfBaseComponent.InvokeMethod(String methodName, Object[] methodParams)
at Syncfusion.Blazor.Popups.SfDialog.ComponentDispose()
at System.Threading.Tasks.Task.<>c.b__139_0(Object state)
at Microsoft.AspNetCore.Components.Rendering.RendererSynchronizationContext.ExecuteSynchronously(TaskCompletionSource`1 completion, SendOrPostCallback d, Object state)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
--- End of stack trace from previous location where exception was thrown ---
at Microsoft.AspNetCore.Components.Rendering.RendererSynchronizationContext.ExecuteBackground(WorkItem item)
Other details:
- View: month
- Version: 18.2.44 and 18.2.45
I'm looking for a way to do this correctly, maybe Syncfusion knows a cleaner method to avoid these problems.
Thank you.