dhtmlxscheduler - eliminate Saturday and sunday

Hi, I’m trying your product. Is there anyway to create a Scheduler View from “Monday to Next Monday” without showing Saturday and Sunday?. I’ve tried your W-Week example and, although it worked, I can’t move an event from one week to another in the W-Week view, and the month view is less flexible.



Thanks.


Hello


it is possible to show days from Monday to Next Monday, but Sat and Sun can not be excluded.


In the sample with W_Week


scheduler.date.get_workweek_end=function(date){ return scheduler.date.add(date,5,“day”); }


can be changed with


scheduler.date.get_workweek_end=function(date){ return scheduler.date.add(date,8,“day”); }


The event that are created in Sat and Sun can be deleted:


scheduler.attachEvent(“onEventAdded”, function(event_id,e){
var event = this.getEvent(event_id)
var day = event.start_date.getDay();
if(day==6 || day==0) this.deleteEvent(event_id)
});



Mmmhh… ok. maybe I’m not explaining myself correctly. Please excuse my english, I’m an spanish speaker. I’ve got 2 problems:
Moving events and column width.

Firs of all I need to move Events from one week to the other. I’ve solved this, in your W-Week example doing the next thing:

scheduler.date.add_workweek=function(date,inc){

                        return scheduler.date.add(date, inc*1, “day”);

                    }

so now I’m able to move day by day the scheduler, so I can drag and drop the events between week. I’ve also make this other two changes:

scheduler.date.workweek_start=function(date){
    return this.date_part(this.add(date,-1,“day”));

scheduler.date.get_workweek_end=function(date){

                        return scheduler.date.add(date, 4, “day”);

                    }

this allows me to have more width columns. (showing only four days.) and I’ve start the week “yesterday”, so it’s more useful to me at least.

But. I never work on weekends, or at least, I don’t schedule events on weekends, so to me, Saturdays and Sundays are only “Visual trash”.
I need to show at least four days to be able to move one event from Friday to Monday, and I need the column width because I have many
events at the same time.

So my Ideal “W-Week” would be showing three days (yesterday, today and tomorrow) and avoid showing Saturdays and Sundays.

Would that be possible?.  Thank you very much for your patience. And once again excuse my english.

I’ve attached a print screen of my schedule “W-Week” with the modifications that I mentioned.


In the week view ( and custom views, which are based on it ) you can’t have a “holes”.
You can show any number of days, but it is not be possible to skip some of them.
The day after friday will be a saturday or end of view.

Unfortunately I don’t see any simple workarounds to implement required use-case. Possible solution will require some changes in the core of scheduler, if you interested I can provide more info about possible code customization.

thank you very much. Of course I’m interested, but, the thing is that I need to make the changes in “a view”. I mean, I also keep the regular week view and in that view I keep Saturdays and Sundays. If the change you’re thinking of can affect only a “custom view”, I’m listening. Once again thank you very much for your time.

a) in dhtmlxscheduler.js locate _mouse_coords and replace

pos.x=Math.max(0,Math.ceil(pos.x/this._cols[0])-1);

with


var summ = pos.x;
pos.x=-1;
while (summ>0){
summ-=this._cols[0];
pos.x=pos.x+1;
}

it will not cause visible effect, just allow to use different width for different columns, which we will use on next step

b) create custom w-week view




//work week
scheduler.date.workweek_start = function(date){ return this.date_part(this.add(date,-1,“day”)); }
scheduler.templates.workweek_date = scheduler.templates.week_date;
scheduler.templates.workweek_scale_date = scheduler.templates.week_scale_date;
scheduler.date.add_workweek=function(date,inc){ return scheduler.date.add(date, inc*1, “day”); }
scheduler.date.get_workweek_end=function(date){ return scheduler.date.add(date, 4, “day”); }



c) adjust get_workweek_end to get extra days, when sunday or saturday are visible


scheduler.date.get_workweek_end=function(date){
var step;
if (date.getDay()==1 || date.getDay()==2)
step=4;
else if (date.getDay()==0)
step=5
else
step=6;

return scheduler.date.add(date, step, “day”);
}

now you will have 4 working days in which view

d) hide sunday and saturday by modifying _reset_scale in dhtmlxscheduler.js

locate


for (var i=0; i<count; i++){
this._cols[i]=Math.floor(summ/(count-i));


and replace as


var jj = 0;
for (var i=0; i<count; i++){
if (this._mode == “workweek”){
if (d.getDay()==0 || d.getDay()==6){
this._cols[i]=0;
} else {
this._cols[i]=Math.floor(summ/(4-jj));
jj++;
}
} else
this._cols[i]=Math.floor(summ/(count-i));



1263811194.zip (45.8 KB)

What changes would I make to display 5 days in this example.

Thanks

If you need to see 5 days, you can check the sample of workweek, which can be created without complex coding

samples\02_customization\07_custom_view.html