problem coloring events

Hey guys,

I copied the example for coloring events 1:1 into my projects, but it does not work.

It seems like “scheduler.templates.event_class = function(start, end, event)” does not get the event-object, and so the function always returns undefined. From where does this function get the event-object ?

Here are my relevant code-lines, I hope somebody can help.

scheduler.locale.labels.section_custom = "Type";
...
scheduler.templates.event_class = function(start, end, event) {

            if (event.custom)
                return "event_" + event.custom;
        };

scheduler.config.lightbox.sections = [
....
            {name: "custom", height: 23, type: "select", options: event_types, map_to: "event_art"},
....
        ];

Event object will be provided automatically, as third parameter of event ( method will be called each time when event repainted )

The above code must be enough to implement custon styling for events.

Try to add !important flag to the colors in custom css rules.
If issue still occurs - please provide some kind of sample.

when I delete “if (event.custom)”
the class “event_undefined” is added to the div. So the problem is in the javascript, not in the css.

So I think the event object is not transmitted correctly ?!

Is it correct, that I check the section-name defined in scheduler.locale.labels and below in the scheduler.config.lightbox.sections ?

just tried

return "event_" + event.description;

and it also returns event_undefined

When saving data from lightbox it will use name value from config of related section
So if you have some property with name=“custom” it will store its value as ev.custom

When loading data from the server side it will use data from json ( lightbox configuration doesn’t matter )

I am sorry, I don’t get your point. So the code I used is correct, isn’t it ?

The code which you are using looks fine, and must work correctly. ( if you have correct data of course )

If you have some kind of online demo where the incorrect behavior can be checked - please provide the link.

Ok, I will put it online, thanks for your help so far.

I just fixed it, but I don’t know what the problem was. Either it was, that the column in the database was not called like the section in the code or it was the position of some codelines, which I changed.

Thanks anyways! :slight_smile: