Hi,
We are using Signal R to update the data source of our scheduler, we are only passing the newly added object not the entire datasource via Signal R. We've tried just adding the new object to the data source (and calling State Has Changed) but that doesn't work and we don't really want to get all the data again if we can help it. Edit: We can't get all the data again as we are getting an exception "cannot access a disposed object" which seems to be when we include an EventTemplate.
How should this work? We've tried all the Syncfusion and SignalR samples we can find online and they don't work, we just need a Scheduler refresh method, which all the other controls seem to have.
Thanks,
Alex
HubConnection connection;
protected override async Task OnInitializedAsync()
{
connection.On<List<AppointmentData>>("RecieveData", OnDataChange);
connection.On<View>("ChangeView", OnChangeView);
connection.On<DateTime>("ChangeDate", OnChangeDate);
await connection.StartAsync();
}
public void OnActionCompleted(ActionEventArgs<AppointmentData> args)
{
if (args.ActionType== ActionType.EventCreate || args.ActionType == ActionType.EventRemove || args.ActionType == ActionType.EventChange)
{
connection.InvokeAsync("SendData", DataSource);
}
}
public void OnNavigating(NavigatingEventArgs args)
{
if (args.Action == "view")
{
connection.InvokeAsync("SendViewData", Enum.Parse(typeof(View), args.CurrentView.ToString(), true));
}
if (args.Action == "date")
{
connection.InvokeAsync("SendSelectedDateData", args.CurrentDate);
}
}
Task OnChangeView(View view)
{
this.CurrView = view;
this.StateHasChanged();
return Task.CompletedTask;
}
Task OnChangeDate(DateTime date)
{
this.SelectedDate = date;
this.StateHasChanged();
return Task.CompletedTask;
}
Task OnDataChange(List<AppointmentData> data)
{
this.DataSource = data;
this.StateHasChanged();
return Task.CompletedTask;
} |
public class ScheduleHub:Hub
{
public async Task SendData(List<Index.AppointmentData> data)
{
await Clients.Others.SendAsync("RecieveData", data);
}
public async Task SendViewData(View data)
{
await Clients.Others.SendAsync("ChangeView", data);
}
public async Task SendSelectedDateData(DateTime data)
{
await Clients.Others.SendAsync("ChangeDate", data);
}
} |
Hi, as already mentioned we are not sending (nor I doubt would anyone) all the data again in the SignalR event (and we've already seen this example - as mentioned above)
Task OnDataChange(List
it is only the new appointment
Task OnDataChange(AppointmentData data)
so we need a way to refresh the scheduler
Thanks,
Alex
Hi, any update on this? It's a major blocker at the moment.
public void OnActionCompleted(ActionEventArgs<AppointmentData> args)
{
if (args.ActionType == ActionType.EventCreate || args.ActionType == ActionType.EventRemove || args.ActionType == ActionType.EventChange)
{
connection.InvokeAsync("SendData", args.AddedRecords, args.ChangedRecords, args.DeletedRecords);
}
}
Task OnDataChange(List<AppointmentData> addedData, List<AppointmentData> changedData, List<AppointmentData> deletedData)
{
List<AppointmentData> appointmentData = this.DataSource.ToList();
if (addedData != null && addedData.Count > 0)
{
foreach(AppointmentData data in addedData)
{
appointmentData.Add(data);
}
}
if (changedData != null && changedData.Count > 0)
{
foreach (AppointmentData data in changedData)
{
int index = appointmentData.FindIndex(m => m.Id == data.Id);
if (index >= 0)
{
appointmentData[index] = data;
}
}
}
if (deletedData != null && deletedData.Count > 0)
{
foreach (AppointmentData data in deletedData)
{
int index = appointmentData.FindIndex(m => m.Id == data.Id);
if (index >= 0)
{
appointmentData.RemoveAt(index);
}
}
}
this.DataSource = appointmentData;
this.StateHasChanged();
return Task.CompletedTask;
} |
Thanks for this - but not quite following how this proves anything? If we comment out all the code below the appointment still gets added so not sure what this is doing? We've tried this on our example and still not working.
This is our code, the reservation is received and we've updated the datasource (this.Reservations) as suggested, the scheduler spinner displays but the reservation is not added.