I’ve managed to track this down to a problem with the id’s but I’m not sure how to fix it. I have a week view and a unit view (Staff member schedules).
I’m using JSON, created from Linq and ASP.NET MVC, to load the scheduler. Here’s a shortened example.
The problem is in the “id”, they are the same because it represents an Appointment ID in my database. The only difference in the 2 events above is the section_id (Staff ID). There are two staff members assigned to the event.
The results of this:
In week view I see 1 event - OK
In unit view I see 1 event only under 1 of the section_id’s - NOT OK
I modified the id so it uses a random number, now both id’s are different. The results of this:
In week view I see 2 events side-by-side - NOT OK
In unit view I see 2 events, one under each section_id - OK
How can I make it so that:
In week view I see 1 event
In unit view I see 2 events, one under each section_id
If you are loading events with the same id when only one (last) event will be actually loaded, that’s why all events should have unique ids.
What can be done to resolve it?
You can assign dummy ids to ‘copies’ of events:
[
{"id":"5","start_date":"2010-10-01 07:00","end_date":"2010-10-01 10:00","text":"My Appointment","section_id":157},
{"id":"5@1","start_date":"2010-10-01 07:00","end_date":"2010-10-01 10:00","text":"My Appointment","section_id":95}
]
here event with id=“5” is ‘true’ event, and “5@1” is a merely first copy of it.
For units view you can display all of them, but for day/week/month views you need to filter them.
If you choose to implement that solution you will that additional handlers will be required, for example, if you edit ‘true’ event in week view and then go to units view dummy events will still have old data.
What additional handlers do I need to make this work? More specifically I need only 1 event to appear in Week view. Currently two or more are showing.
My data structure looks something like this:
EVENTS
id = 1, text = "event 1"
STAFF
event_id = 1, name = "John"
event_id = 1, name = "Mary"
STAFF event_id is a foreign key for EVENTS id.
If I add another field to EVENTS (appt_id=1) is there some sort of filter I can use on Week view like:
if (not appt_id is rendered in scheduler) {
render the event
}
Seems like this would be a common problem since events could have a one-to-many relationship with the people attending the event. I’m just not sure how to solve it within the scheduler
You can filter what events will be displayed in a view following way:
// day here is the mode name
// (so you also can use filter_month, filter_week and so on)
scheduler.filter_day = function(event_id, event){
if(event.type == 3)
return false; // now all events with the type = 3 won't be rendered
return true; // event will be rendered
};
Best regards,
Ilya