Resources groups

Hi,

no, most likely, problem is in the reference, since this exception was thrown by serializer.
Check your models, orm can automatically build relations between them, and the linked objects will have references to each other. If you are using linq to sql, this issue can be fixed by editing the ‘Child Property’ of ‘Parent Property’ of the association between the models.

Thank you again Aliaksandr.

  1. So what you saying is that I cannot have any circles anywhere inside my model, not even related to events table, correct?

  2. Is that the reason in every sample I saw so far from dhtmlx events table always stands alone and glued with the rest of the model by Linq2SQL?

  3. I use Entity Framework (rather than Linq2SQL), the model is like this:
    event<->resource->resource type->user. Basically the same you had with rooms, but with more abstraction: can be room, can be person, can be anything.
    So instead of querying user’s events directly, I will have to join users to resource types to resources to events. It will make my DB queries extremely inefficient, don’t you think?
    It will practically make the model non scalable, because this 3 level join will take forever to perform having millions of records in every table.

  4. What would you suggest in this case, if I cannot have loops in the model. Or am I getting it wrong and missing something?

Thank you again for your prompt help and support

1)No, you can’t have loops in the data which is passed to ‘SchedulerAjaxData’, since the data should be serialized to json, and json doesnt support circular references

2)actually i’m not sure why this part done exactly so) Events could be linked to the Rooms in the model as well. It will work if ‘Child Property’ of the the association will be disabled(ie Event won’t have link to related Room object, which is not essential for the samples)

3)I’m not sure if custom join will be much slower than quering model property. I mean that at the database level all of it will be done using sql queries

4)Maybe, in the Data action, you could select events as the objects of some other type, with only those properties, that will be used on the client, something like

.Select(ev => new RenderableEvent{ id = ev.id, text = ev.text, resourceId = ev.resourceId ,..})
where RenderableEvent will be the class with same properties as Event, except of link to the related Resource object

We plan to make data rendering more flexible, but for now there is no exact date when it will be updated

Hello again!
I found much nicer solution that does the job: instead of sending domain objects into the control (which have loops in data model), I want to create a viewmodel that has all the required fields of event (id, start_time etc including the recursion fields, rec_type, event_pid and event_length).
So I map domain event list into ViewModel one and send it to the control, which displays it beautifully.
Now: events that are non recursive are inserted, updated and deleted from the database alright.
As soon as I enable recursion on the event I get this exception from the control when trying to save it (before I get to Save action in the control):

Microsoft JScript runtime error: Unable to get value of the property ‘id’: object is null or undefined
if I ignore it, next exception is
Microsoft JScript runtime error: Unable to get value of the property ‘type’: object is null or undefined
and so on

These completely make no sense to me and I need your help, please.
Thank you in advance.

Aliaksandr,
Please find the project attached. I am kinda confident you’ll need to debug the code in order to see for yourself what’s going on.
Exceptions are clearly thrown from the scheduler before code even reaches the Save action.
I see no reason for and have no explanation to those exceptions.
Will PM you the password to the archive separately.
The scenario is
modify existing event or create new one
enable the recursion
hit the save button

Note that you will need to install AutoMapper and EntityFramework to compile this.
Thank you in advance!

… and now with the attachment :laughing:
Testing DHTMLX Scheduler.zip (1.12 MB)

Hello,
there is a strange bug in lightbox, recurring control works incorrectly if it’s placed after time-picker control. And its also sensitive to the name of that control. Sorry for the inconvinience, this bug will be fixed in one of upcoming updates.
As workaround you can use following configuration

scheduler.Lightbox.Add(new LightboxRecurringBlock("rec_type", "Recurring")); scheduler.Lightbox.Add(new LightboxMiniCalendar("time", "Time") { MapTo = "auto" }); -RecurringBlock goes before mini calendar, and there is a few more magic values - name of the time-picker should be ‘time’, and it must be mapped to the ‘auto’ property

Thank you very much Aliaksandr.
I could figure it out on my own :slight_smile: .

Hi Aliaksandr,
I have found another very peculiar behaviour that you guys should look into:
in the following like, taken from your examles there’s hardcoded value of “room_id”.

var unitsView = new UnitsView(resourceType.Name, "room_id") { Label = resourceType.Name };

I tried to change it to my own ID values of my own object and unexpectedly (actually I was expecting this having working with scheduler control for some time now) refuses to add/update/delete events throwing exception of incorrect formatting at the following line:

var action = new DataAction(actionValues);

Funny thing is that I don’t have no rooms object in my code any more, but without that “room_id” the control is acting up.
For you to look into and for users to take into account.
Thanks & hope it helps somebody else as well.

Hello Aliaksandr,

In the example you’ve provided in this topic you have room_id as a resource attached to the event.
In situation when there’s dynamic list of multiple resources (x resources for 1 event and y resources for the other) I’ll have to have many to many relationship between events and resources, something like this: Event<---->Resource and in between event and resource tables there is link (or junction or cross-reference) table like this: (int EventID, int ResourceID).

My specific question is: how can I retrieve the list of resources that returns from control as soon as I hit “Save” button?
Can you please provide some sample code for that (the list setting up and the retrieving parts)?

Thank you in advance!

Hi,
control sends values in the request form, they will have same names as the properties of the model. They can be accessed like

var resourseId = this.Request.Form["ResourceId"] orpublic ActionResult Save(int? id, FormCollection actionValues){ var resourseId = actionValues["ResourceId"]

Aliaksandr,

In the example you provided there’s “room_id” field that is part of event.
In my case I don’t keep room_id as part of event: I have many to many relationship with resources and they can be of different types: rooms, clients, students etc.
The list is dynamic so I don’t know in advance how many, hence I cannot define fields on the event it has to be many to many. Its kept in [event_id <-> resource_id] table.

My problem is when scheduler is opened I cannot find a way to preselect the right resource in the LightboxSelect (one selected by user in time of saving).
It always shows the first option on the list, no matter what I try.

Can you please explain how to do that?

Thank you in advance!