Learner
Learner

Reputation: 1315

KendoUI scheduler Week view :-how to get date of start of week

I am using KendoUI scheduler in my application. is there any way to get the start of week when the selected view is week.

Upvotes: 0

Views: 1556

Answers (1)

Satya Ranjan Sahoo
Satya Ranjan Sahoo

Reputation: 1086

Yes. Use the navigate event to catch current date and get the start of week by manipulating the retrieved date. i.e.

navigate: function (e) {
           if (e.view.toLowerCase() === "week") {
                GetStartDateOfWeek(e.date);
             }
  }

function GetStartDateOfWeek(d) {
  d = new Date(d);
  var day = d.getDay(),
  diff = d.getDate() - day + (day == 0 ? -6:1); // adjust when day is sunday
  var startOfWeek = new Date(d.setDate(diff));
 }

Hope it helps!

Reference: JavaScript - get the first day of the week from current date

Upvotes: 1

Related Questions