Change the width of events in the Kendo UI Scheduler

I am building a website in HTML5 and javascript. One of the sites contains Kendo UI Scheduler . I understand the scheduler and how it works, and I managed to set up a simple scheduler with some events. Now my problem is that I want to change the way events are added to the scheduler; I want to resize events by half the size of the column in which they are displayed. Is there an easy way to do this, or do I need to change the Kendo code that calculates the position of these events?

+4
source share
3 answers

Since no one could answer this question for me, I am posting my own solution: I tried to do this using CSS, but I could not get it to work. Instead, I decided to redefine the Kendo UI code, which decided on the events of the scheduler.

        //Override kendo function for deciding events with
        kendo.ui.MultiDayView.fn._arrangeColumns = function (element, top, height, slotRange) {
            var startSlot = slotRange.start;

            element = { element: element, slotIndex: startSlot.index, start: top, end: top + height };

            var columns,
                slotWidth = startSlot.clientWidth,
                eventRightOffset = slotWidth * 0.10,
                columnEvents,
                eventElements = slotRange.events(),
                slotEvents = kendo.ui.SchedulerView.collidingEvents(eventElements, element.start, element.end);

            slotRange.addEvent(element);

            slotEvents.push(element);

            columns = kendo.ui.SchedulerView.createColumns(slotEvents);

            //This is where the magic happens
            var columnWidth = slotWidth / 2; 
            //Original code: var columnWidth = (slotWidth - eventRightOffset) / columns.length;
            //This is where the magic ends

            for (var idx = 0, length = columns.length; idx < length; idx++) {
                columnEvents = columns[idx].events;

                for (var j = 0, eventLength = columnEvents.length; j < eventLength; j++) {
                    columnEvents[j].element[0].style.width = columnWidth - 4 + "px";
                    columnEvents[j].element[0].style.left = (this._isRtl ? this._scrollbarOffset(eventRightOffset) : 0) + startSlot.offsetLeft + idx * columnWidth + 2 + "px";
                }
            }
    };
+7
source

I am using override css

.k-event {

        clear: both;
        margin:3px 2px 3px 2px;
        padding:3px 1px 3px 1px;
        border-radius: 2px;
        border: solid 1px rgba(100, 100, 100, 0.5);
        -webkit-box-shadow: 0px 2px 2px rgba(100, 100, 100, 0.5);
        box-shadow: 0px 2px 2px rgba(100, 100, 100, 0.5);
        height:auto !important;
        width:90px !important;
        overflow-y:auto;
        text-align:center;
        text-justify:auto;
        text-shadow:0px 0px 2px rgb(200, 200, 200);
        color:#101010;
    }

attach "! important" to force the usage width to your preference.

:)

+2
source

dataBount, :

dataBound: function (e) {       var events = $(e.sender.element).find( ". k-event" ). height (65); },

-2

All Articles