How to: Week (one row) View?


#1

Enterprise customer here hoping you can help.

What is needed to make the Schedule have the ability to show one week (Sunday - Saturday) only? It’s the same as the Month view but I only want to show one week.

This will be a feature we will use that allows the customer to see what is taking place for this week. Because of the way this is used, we do not need to display the whole month as that will be visible on another page.

It will look like this. Here we have the details from Gantt showing in Schedule.

Thanks!


#2

Hi @Osensnolf,
I’m sorry for such a long delay. Unfortunately, there is no built-in method to change the rendering of the Month view. But you can redefine some internal functions.
First of all, you should set a start and end date for your view:

var getViewEnd = scheduler._get_view_end;
scheduler._get_view_end = function(){
  if(scheduler.getState().mode !== "month"){
    return getViewEnd.apply(this, arguments);
  }
  var dd = this._get_timeunit_start();
  return scheduler.date.add(dd, 1, "week");
};

var getViewStart = scheduler._get_timeunit_start;
scheduler._get_timeunit_start = function(){
  if(scheduler.getState().mode !== "month"){
    return getViewStart.apply(this, arguments);
  }
  return this.date.week_start(new Date(scheduler.getState().date));
};

Then, please, redefine the behavior of the next/previous buttons:

var nextBtn = scheduler._click.dhx_cal_next_button;
scheduler._click.dhx_cal_next_button = function(dummy,step){
  if(scheduler.getState().mode === "month"){
    scheduler.setCurrentView(scheduler.date.add(
    scheduler.date.week_start(new Date(scheduler._date)),(step||1),"week"));
  }else{
    nextBtn.apply(this, arguments);
  }
}

And finally, change the way of rendering the month scale (display only one week):

var resetMonthScale = scheduler._reset_month_scale;
scheduler._reset_month_scale = function (b, dd, sd, rows) {
    return resetMonthScale.apply(this, [b, dd, sd, 1]);
};

You can see the implementation of this way in the sample below:
http://snippet.dhtmlx.com/5/fd8e76119

Please, note, if you update the scheduler the app can stop working.


#3

Thank you VERY much. This is what we needed to complete the tasks.