Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by mahesh on Oct 31, 2009 11:53
open dhtmlx forum
dhtmlx scheduler and double click default

On the calendar, when I double-click on month view is there a way to change the default times for an event without altering the click and drag functionailty on the day view.
Answer posted by Alex (support) on Nov 02, 2009 03:32

Hello,

you can redefine time block as follows:


var setter = scheduler.form_blocks.time.set_value;

scheduler.form_blocks.time.set_value=function(node){
    var sels = node.getElementsByTagName("SELECT");
    setter.apply(this,arguments);
    if(scheduler._new_event&&scheduler._mode=="month"){
        sels[0].value = minutes;

         sels[4].value = minutes;
    }
}

Where minutes - the default value in minutes. For example 90 or 480.

Answer posted by mahesh on Nov 02, 2009 08:59
Almost worked.  I set sels[0].value = minutes;

         sels[4].value = 480;
sels[0].value = minutes;

         sels[4].value = 60;

and the start time is great at 8 AM, but the end time carries me to the next day, the 24th at 1 AM; and if the 2nd argument is 540 it brings me to the next day at 9 AM.

Answer posted by mahesh on Nov 02, 2009 09:01
sorry, I menat sel[0].value=480
Answer posted by Alex (support) on Nov 02, 2009 09:19

Locally the following approach works correctly. Dates in from and to blocks show the same days:

var setter = scheduler.form_blocks.time.set_value;

scheduler.form_blocks.time.set_value=function(node){
  var sels = node.getElementsByTagName("SELECT");
  setter.apply(this,arguments);
  if(scheduler._new_event&&scheduler._mode=="month"){
     sels[0].value = 480;
     sels[4].value = 540;
  }
}


Answer posted by mahesh on Nov 02, 2009 09:31

This is what I am using, still wants to go to the next day.

 

<script type="text/javascript" charset="utf-8">
 function init() {
       
        //scheduler.config.readonly=1;
                //scheduler.config.show_loading=true;


                scheduler.config.time_step = 60;
                scheduler.config.multi_day=0;
                scheduler.config.xml_date="%Y-%m-%d %H:%i";
                scheduler.config.hour_size_px=75;
  scheduler.config.lightbox.sections=[ 
   {name:"description", height:80, map_to:"text", type:"textarea" , focus:true},
   {name:"location", height:60, type:"textarea", map_to:"details" },
   {name:"time", height:72, type:"time", map_to:"auto"}
  ]
  
                scheduler.config.first_hour=7;
                scheduler.config.last_hour=19;
                scheduler.config.hour_date="%h:%i%A";

               //Set time on month view on double click
              var setter = scheduler.form_blocks.time.set_value;
              scheduler.form_blocks.time.set_value=function(node){
              var sels = node.getElementsByTagName("SELECT");
              setter.apply(this,arguments);
              if(scheduler._new_event&&scheduler._mode=="month"){
              sels[0].value =480;
              sels[4].value =540;
                 }
              }
              //End select default hours on double click

Answer posted by Alex (support) on Nov 03, 2009 03:26
Locally \tThe same code works correctly - sample is attache
Attachments (1)
sample.zip38.26 Kb
Answer posted by mahesh on Nov 03, 2009 10:16

Alex,

  The sample you provided works fine, but the website implementation fails:

http://www.vmcrad.org/xcal/schedules/init_loading/aconf.html

Could it be due to PHP time definition or settings?

Answer posted by mahesh on Nov 03, 2009 21:01

Alex,

actually, I uncoverered some other eccentricities:

1.  On the sample, the upper left of the yellow box has a different time on month double click.,

2. On the sample, sometimes double clicking on the month gives a different time

 

On

http://www.vmcrad.org/xcal/schedules/init_loading/aconf.html

dragging an event from one box to another changes the time.

quite strange.

Answer posted by Alex (support) on Nov 04, 2009 01:50
Hello,

to solve the issue with time in header you can try to use the following approach:

event_header_old = scheduler.templates.event_header;
scheduler.templates.event_header = function(start_date,end_date,ev){
     if(scheduler._new_event&&scheduler._mode=="month")
         return "8:00AM - 9:00AM";
     else return event_header_old.apply(this,arguments);
}
Regarding the others issues with sample on the website -they were not reproduced.
Answer posted by mahesh on Nov 04, 2009 08:20

thanks, the sample seems ok, although the version I have:

http://www.vmcrad.org/xcal/schedules/init_loading/aconf.html

when I click on the event in month view, the time changes by 1 hour, and when I move from one day to another in month view the time changes again by more that that.  Still quite puzzling.

Answer posted by mahesh on Nov 04, 2009 08:20

thanks, the sample seems ok, although the version I have:

http://www.vmcrad.org/xcal/schedules/init_loading/aconf.html

when I click on the event in month view, the time changes by 1 hour, and when I move from one day to another in month view the time changes again by more that that.  Still quite puzzling.

Answer posted by Stanislav (support) on Nov 04, 2009 10:03
Which timezone is configured on your PC ?
Answer posted by mahesh on Nov 04, 2009 10:14

pacific time

automatic adjustment for daylight savings

Answer posted by mahesh on Nov 04, 2009 10:15
the same problem occurred when I tried a friends computer
Answer posted by mahesh on Nov 04, 2009 17:45

Partial debugging follows:

Commenting out line

 //scheduler.config.time_step = 60;

results in not changing to the next day on the web based calendar.

 

The time and date fluctuations when dragging an event from one day to another are peculiar to the month of Nov seemingly.  When I click on a time in month view in the upper part of the box, the time decreases by 1 hour, and when I drag the same thing happens but only for the month of Nov, so this may have to do with daylight savings time.  The are some php bugs in strtotime in the past, or perhaps crossing daylight savings time is not accounted for entirely in the calendar scripts?  When I click and drag on the prior or following month, all is well.

Answer posted by mahesh on Nov 05, 2009 08:04

Alex,

additional  note (please see prior also):  When I change the date&time control panel to not correct for daylight savings time automatically the behaviour reverts to expected for the months of Oct or Nov.  I do not think you can assume what another persons computer is set for though.   Is there a way to account for this? thanks,

Answer posted by Alex (support) on Nov 05, 2009 09:20
Hello,

please try to use the latest (attached) scheduler version. There were some fixes for winter time.


Attachments (1)
Answer posted by mahesh on Nov 05, 2009 12:43

Alex,

  thanks, that solved the problem!