Show full day manually

3 posts, 0 answers
  1. Kumeri
    Kumeri avatar
    10 posts
    Member since:
    Jul 2018

    Posted 03 Jan 2019 Link to this post

    Hi, 

    in the workweekview when I have events with intervals outside of business hours it would be desirable that full day is shown by default. Is there is a way to trigger the show full day command from my side once i know there are events outside business hours?  

  2. Dimitar
    Admin
    Dimitar avatar
    796 posts

    Posted 07 Jan 2019 Link to this post

    Hi Kumeri,

    In general, the described behavior could be achieved as follows:


    I have prepared a Dojo example, where the above functionality is implemented as follows:
    dataBound: function(e) {
        var scheduler = e.sender;
        var view = this.view();
         
        if (!view.startTime || !view.endTime) {
            return;
        }
     
        var events = this.dataSource.expand(view.startDate(), view.endDate());
     
        var startTime = kendo.date.getMilliseconds(view.startTime());
        var endTime = kendo.date.getMilliseconds(view.endTime());
        var showPrev;
        var showNext;
     
        for (var idx = 0; idx < events.length; idx++) {
            if (events[idx].isAllDay) {
                continue;
            }
     
            if (kendo.date.getMilliseconds(events[idx].start) < startTime) {
                showPrev = true;   
            }
     
            if (kendo.date.getMilliseconds(events[idx].end) > endTime &&
                endTime > startTime) {
                showNext = true;   
            }
        }
     
        if(showPrev || showNext) {
            $(scheduler.wrapper.find(".k-scheduler-fullday .k-link")[0]).click();  
            $(scheduler.wrapper.find(".k-scheduler-fullday .k-link")[0]).hide();
        }
    }

    Important to note is that in order for the above behavior to work, the Scheduler's "Show Business Hours" button has to be hidden. Otherwise, clicking on it will trigger the dataBound event again and the view state will not be changed.

    I hope this helps.

    Regards,
    Dimitar
    Progress Telerik
    Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
  3. Kumeri
    Kumeri avatar
    10 posts
    Member since:
    Jul 2018

    Posted 23 Jul 2019 in reply to Dimitar Link to this post

    Thank you 
Back to Top