Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by mount on Nov 25, 2009 06:51
open dhtmlx forum
shared calendars, diferent lightwindow

Hi
I can display correctly two diferent calendars in two diferent colors in the scheduler.
I've added a combo in the lightbox that displays the source calendar of the event. So, when a new event is created, the user can choose the calendar where insert it.
I would like to change the color of the lightbox background in order to make easier and more clear the calendar selection for users.
How can I this to work?
Is there a way similar to scheduler.templates.event_class for the ligthbox?
Thanks
Answer posted by Alex (support) on Nov 25, 2009 07:47

Hello,

you can try to use the following approach to set the background-color of lightbox:

scheduler.attachEvent("onBeforeLightbox", function (event_id){
   var color = scheduler.getEvent(event_id).color;
   if(color)
       scheduler._get_lightbox().style.backgroundColor = color;
   return true
});


Answer posted by mount on Nov 26, 2009 08:11
Thanks, it works fine, but only for the border of the box.
My goal is to get the same efect even when the lightbox is visible, and the user selects a diferent calendar where to set his event.
Whith this approach it is clear to the user the choosen calendar.
My code is:

        scheduler.config.xml_date = "%Y-%m-%d %H:%i";
        scheduler.config.show_loading = true;
        scheduler.config.first_hour = 9;
        scheduler.config.last_hour = 22;
        scheduler.config.time_step = 15;
        scheduler.config.lightbox.sections=[
            { name:"description", height:50, map_to:"text", type:"textarea", focus:true},
            { name:"type", height:21, map_to:"calId", type:"select", options:[
                {key: 1, label: "calendar1"},
                {key: 2, label: "calendar2"}
            ]},
            { name:"time", height:90, type:"time", map_to:"auto"}   
        ];


and I wrote this function:

var setter=scheduler.form_blocks.select.set_value;
scheduler.form_blocks.select.set_value=function(node,value,ev){
    s=node.getElementsByTagName("select");
    for(var i=0; i<s.length;i++)
        s[i].onchange=checkColor;
    setter.apply(this,arguments);
}
checkColor=function(e){
    var color=(s[0].value == 1)?"#FFE763":"#FF8040";
    scheduler._get_lightbox().style.backgroundColor=color;
}


but s[] takes the values from the time section, and not from the select section. I tried to use var setter=scheduler.form_blocks.select.set_value; but I get an exception.

How can I get the value of the select in the "type" section?

Answer posted by mount on Nov 26, 2009 08:15
Reading my answer I found a mistake near its bottom. Where I wrote:

I tried to use var setter=scheduler.form_blocks.select.set_value;

I wanted to write:

I tried to use var setter=scheduler.form_blocks.type.set_value;

Thanks
Answer posted by mount on Nov 26, 2009 08:15
Thanks, it works fine, but only for the border of the box.
My goal is to get the same efect even when the lightbox is visible, and the user selects a diferent calendar where to set his event.
Whith this approach it is clear to the user the choosen calendar.
My code is:

        scheduler.config.xml_date = "%Y-%m-%d %H:%i";
        scheduler.config.show_loading = true;
        scheduler.config.first_hour = 9;
        scheduler.config.last_hour = 22;
        scheduler.config.time_step = 15;
        scheduler.config.lightbox.sections=[
            { name:"description", height:50, map_to:"text", type:"textarea", focus:true},
            { name:"type", height:21, map_to:"calId", type:"select", options:[
                {key: 1, label: "calendar1"},
                {key: 2, label: "calendar2"}
            ]},
            { name:"time", height:90, type:"time", map_to:"auto"}   
        ];


and I wrote this function:

var setter=scheduler.form_blocks.select.set_value;
scheduler.form_blocks.select.set_value=function(node,value,ev){
    s=node.getElementsByTagName("select");
    for(var i=0; i<s.length;i++)
        s[i].onchange=checkColor;
    setter.apply(this,arguments);
}
checkColor=function(e){
    var color=(s[0].value == 1)?"#FFE763":"#FF8040";
    scheduler._get_lightbox().style.backgroundColor=color;
}


but s[] takes the values from the time section, and not from the select section. I tried to use var setter=scheduler.form_blocks.select.set_value; but I get an exception.

How can I get the value of the select in the "type" section?

Answer posted by Alex (support) on Nov 27, 2009 04:17
Please, try to use the attached version instead of the original one. It will solve the issue
Attachments (1)
Answer posted by mount on Nov 30, 2009 04:37

Alex,

thank you for your post. The file works fine, but I get two problems:

scheduler.config.multi_days=true; does not work,

scheduler.config.show_loading=true; works but the loading icon does not disappear when the data is loaded. Not a big problem, by the way, I just set this to false.

Answer posted by Alex (support) on Nov 30, 2009 06:47

The correct property name is multi_day instead of .multi_days:

scheduler.config.multi_day = true;

The issue with show_loading property is confirmed. It will be fixed in the next scheduler version (the version will be released in few days).

Answer posted by mount on Nov 30, 2009 08:04
ok. thanks