I currently have the following extended MutliDayView I'm using to hide/show days of the week. The days to show are selected from checkboxes on the page.
I have subscribed to the onClick event for checkboxes. I want to add or remove dates from the view. Here is the code
However, I cannot get this to work. The only way I can get it to work is change the view from my custom view to another one, make the checkbox changes and then select the custom view again. I have to comment out the event code when using this workaround.
Any suggestions?
var customView = kendo.ui.MultiDayView.extend({ name: "customview", calculateDateRange: function () { var startDate = this.options.date; var date = startDate.getDate(); var day = startDate.getDay(); var weekStart = new Date(startDate.setDate(date - day)); var weekDate = weekStart.getDate(); // Array to hold the dates that are displayed var dates = new Array(); // Array to hold all the days of the week var weekDays = new Array(); for (var i = 0; i < 7; i++) { weekDays[i] = new Date(weekStart.setDate(weekDate + i)); } // Get Selected Days to show from checkboxes var checkboxes = document.getElementsByName('weekday'); for (var i = 0; i < checkboxes.length; i++) { // Only add days checked if (checkboxes[i].checked) { // DOW var dayNumber = parseInt(checkboxes[i].value); dates.push(weekDays[dayNumber]); } } this._render(dates); }});I have subscribed to the onClick event for checkboxes. I want to add or remove dates from the view. Here is the code
function weekDayClick(cb){ // Get current view var scheduler = $("#scheduler").data("kendoScheduler"); var currentView = scheduler.view(); // If the current view is not "My View", we can just return if (currentView.title.toLowerCase() != "my view") return; // Is My View. If Checked, need to add to view; otherwise remove var dates = currentView._dates; var newDates = new Array(); var dow = parseInt(cb.value); if (cb.checked) { // TODO: Add selected day to dates } else { // Remove date from view for (var i = 0; i < dates.length; i++) { if (dates[i].getDay() != dow) newDates.push(dates[i]); } } // Render view currentView.render(newDates); scheduler.view(scheduler.view(customView)); scheduler.view(scheduler.view().name);}However, I cannot get this to work. The only way I can get it to work is change the view from my custom view to another one, make the checkbox changes and then select the custom view again. I have to comment out the event code when using this workaround.
Any suggestions?