in my case week start day is a variable (var weekstart = 1;1-mon,2-tue … 7-sunday).
how can i set the week start date using scheduler.date.week_start function ?
Hi,
PLease try this
[code]if(strWeekStartDay==“SUNDAY”)
intDayId = 0;
else if(strWeekStartDay==“MONDAY”)
intDayId = 1;
else if(strWeekStartDay==“TUESDAY”)
intDayId = 2;
else if(strWeekStartDay==“WEDNESDAY”)
intDayId = 3;
else if(strWeekStartDay==“THURSDAY”)
intDayId = 4;
else if(strWeekStartDay==“FRIDAY”)
intDayId = 5;
else if(strWeekStartDay==“SATURDAY”)
intDayId = 6;
if(scheduler.getState().mode=="week"){
scheduler.date.week_start = function(date) {
var shift = date.getDay();
if (shift === 0)
shift = 2;
else
shift = shift - intDayId;
return this.date_part(this.add(date, -1 * shift, "day"));
};
}[/code]
will this work if onload mode is ‘month’ and user changes it to ‘week’ mode ?
Hi ,
Put the week start function inside the onViewChange event , so that it will call on every view change
scheduler.attachEvent(“onViewChange”, function (new_mode , new_date){
//any custom logic here
});
$scope.schedulerInstance.date.week_start = function(date){
console.log(date);
var intDayId = 0;
if($scope.schedulerconfig.weekStartDay==7)
intDayId = 0;
else if($scope.schedulerconfig.weekStartDay==1)
intDayId = 1;
else if($scope.schedulerconfig.weekStartDay==2)
intDayId = 2;
else if($scope.schedulerconfig.weekStartDay==3)
intDayId = 3;
else if($scope.schedulerconfig.weekStartDay==4)
intDayId = 4;
else if($scope.schedulerconfig.weekStartDay==5)
intDayId = 5;
else if($scope.schedulerconfig.weekStartDay==6)
intDayId = 6;
var shift = date.getDay();
if (shift == 0)
shift = 2;
else
shift = shift - intDayId;
return this.date_part(this.add(date, -1 * shift, "day"));
};
what you have gien is working fine but in the month view when ever month starts with sunday then it is not working correctly.
this worked for me
$scope.schedulerInstance.date.week_start = function(date){
var intDayId = 0;
if($scope.schedulerconfig.weekStartDay==7)
intDayId = 0;
else if($scope.schedulerconfig.weekStartDay==1)
intDayId = 1;
else if($scope.schedulerconfig.weekStartDay==2)
intDayId = 2;
else if($scope.schedulerconfig.weekStartDay==3)
intDayId = 3;
else if($scope.schedulerconfig.weekStartDay==4)
intDayId = 4;
else if($scope.schedulerconfig.weekStartDay==5)
intDayId = 5;
else if($scope.schedulerconfig.weekStartDay==6)
intDayId = 6;
var shift = date.getDay();
if(shift ==0)
{
shift = 7- $scope.schedulerconfig.weekStartDay;
}
else
{
shift = shift - intDayId;
}
if(shift < 0)
{
shift = 7 + shift
}
return this.date_part(this.add(date, -1 * shift, "day"));
};