Radscheduler for Winforms filtering and making updates for entity framework

1 Answer 102 Views
DataEntry Scheduler and Reminder
Jean-Paul
Top achievements
Rank 1
Jean-Paul asked on 06 Jul 2021, 08:13 AM

I am trying to work on a scheduler interface that will allow a user to enter appointments.

The system is working when I apply no filter and load data through the following:

try
{
entities.Appointments.Load();
schedulerBindingDataSource1.EventProvider.DataSource = entities.Appointments.Local.ToBindingList();//filteredAppointmentsByLocation;
this.radScheduler1.DataSource = schedulerBindingDataSource1;
}

The above works and allows me to add, edit and delete without issues.

If I try to add a filter to get specific information:
var filteredAppointmentsByLocation = entities.Appointments.Local.ToBindingList().Where(x => x.LocationID.Equals(ActiveLocation));

and set this as the datasource, I cannot add new items when I do entities.SaveChanges().  I get an error saying it cannot add to a read-only or fixed-size list.  Edits are saved, deletes are not done.

Please advise

1 Answer, 1 is accepted

Sort by
0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 08 Jul 2021, 09:45 AM
Hello, Jean-Paul,

According to the provided information, it seems that you are setting the DataSource to the collection returned by the Where method: https://docs.microsoft.com/en-us/dotnet/api/system.linq.enumerable.where?view=net-5.0 

Such a query will return a list of anonymous objects. The objects in that list are read-only and that is why you cannot edit them. The possible solution that I can suggest is to ensure that you always bind the scheduler to a BindingList collection even after the filtering is applied. Instead of filtering, you can simply hide the redundant appointment.
 
I hope this information helps. If you need any further assistance please don't hesitate to contact me. 

 

Regards,
Dess | Tech Support Engineer, Principal
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Tags
DataEntry Scheduler and Reminder
Asked by
Jean-Paul
Top achievements
Rank 1
Answers by
Dess | Tech Support Engineer, Principal
Telerik team
Share this question
or