Change the width of the events in a Kendo UI Scheduler

微笑、不失礼 提交于 2019-12-06 04:25:41

问题


I am creating a website in HTML5 and javascript. One of the site contains the Kendo UI Scheduler. I understand the scheduler and how it works, and I've managed to set up a simple scheduler with some events. Now, my problem is that I want to alter the way the events is drawn in to the scheduler; I want to alter the size of the events to be half the size of the column they are displayed in. Is there any simple way to do this, or do I have to alter the Kendo code that is calculating the position of these events?


回答1:


Since nobody could answer this for me, I'm posting my own solution: I tried doing this with CSS, but I wasn't able to make it work. In stead I decided to override the Kendo UI code that decided the with of the scheduler events.

        //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";
                }
            }
    };



回答2:


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 use width by your setting.

:)




回答3:


I am also resizing the height with dataBount event as below:

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



来源:https://stackoverflow.com/questions/19487913/change-the-width-of-the-events-in-a-kendo-ui-scheduler

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!