Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by Vineetha on Dec 21, 2009 01:37
open dhtmlx forum
need to prevent the event creation on sat,sun and holiday

Hi

I am using dhtmlxscheduler. I need to prevent the event creation on sat,sun and holidays. For that i have used the following code

scheduler.attachEvent("onBeforeLightbox",function(id){
     var ev = this.getEvent(id);
     var date = ev.start_date;
     var hDay=null;
     if(date.getDay()==0 || date.getDay()==6 ){
         alert("It's a Holiday");
        
        scheduler.deleteEvent(id);
     }
     }
     }
     return (date.getDay()&&date.getDay()!=6 )
    })

Its working. but in this case 1st the event will be displayed then only deleted. I dont want to allow event display when i do drag and double click on those holidays,sat and sun . So would you please tell me the scheduler condition for this instead of 'onbeforelightbox'.

Thank You
Vineetha

Answer posted by Alex (support) on Dec 21, 2009 02:07

Hello,

unfortunately there is no way to get start_date property in onBeforeDrag and onClick event handlers to even creation.

But it is possible not to show Saturday and Sunday in week view at all:

scheduler.date.add_week=function(date,inc){ return scheduler.date.add(date,inc*7,"day"); }

scheduler.date.get_week_end=function(date){ return scheduler.date.add(date,5,"day"); }