This is a migrated thread and some comments may be shown as answers.

Color-code Resource unavailable Days/Hours?

5 Answers 308 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
AceRoute Dev
Top achievements
Rank 1
AceRoute Dev asked on 01 Feb 2014, 07:57 AM
How do I shade days/time slots which a resource may not be available? I am not trying to restrict vent create but simply color-code time-slots.

Also, how do I change color of all time-slots for Saturday/Sunday to light-red?

5 Answers, 1 is accepted

Sort by
0
Vladimir Iliev
Telerik team
answered on 05 Feb 2014, 10:08 AM
Hi,

Please find the answers of your questions below:

1) How do I shade days/time slots which a resource may not be available? - You can use the "dataBound" event of the scheduler to get all slot objects and based on them to apply custom CSS class to the needed elements. Please check the example below:

dataBound: function (e) {
    var scheduler = this;
    var view = scheduler.view();
 
    view.table.find("td[role=gridcell]").each(function () {
        var element = $(this);
        var slot = scheduler.slotByElement(element);
        //your custom logic based on the slot object
        if (true) {
            element.addClass("customClass");
        }
        //based on above logic if needed add custom CSS class to the unavailable slots
    })
},

2) Also, how do I change color of all time-slots for Saturday/Sunday to light-red? - Basically changing the color of given slots is not supported out of the box, however as the "workWeekStart" and "workWeekEnd" options by default are set that the Saturday/Sunday are non-work days, their slots will be rendered with "k-nonwork-hour" CSS class. You can override that class to set the needed background color.

Regards,
Vladimir Iliev
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
AceRoute Dev
Top achievements
Rank 1
answered on 13 Feb 2014, 07:34 PM
Hi Vladimir - Thanks for response. Follow-up question on role=gridcell.

view.table.find("td[role=gridcell]").each(function () {
        var element = $(this);
        var slot = scheduler.slotByElement(element);
        //your custom logic based on the slot object
        if (true) {
            element.addClass("redClass");
        }
}

In my custom logic, how do I check what View/Resource/Date/Hour this slot is for?
Basically, my logic would be as follows:
1) For all slots where view!=Agenda and Resource Group is ON
2) For each Resource, change gridcell color to red if the gridcell hour is resource's non-working date/hour.
0
Vladimir Iliev
Telerik team
answered on 17 Feb 2014, 01:03 PM
Hi,

Basically you should use one of the following methods, however the returned 'slot' object currently doesn't contain information about current group of the slot. That why we decided to include such information and from next internal builds the slot object will contain the current group as well. 

Regards,
Vladimir Iliev
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Marshall Jones
Top achievements
Rank 1
answered on 29 Oct 2014, 02:18 PM
Is the Current Group available yet?
0
Vladimir Iliev
Telerik team
answered on 30 Oct 2014, 09:24 AM
Hello,

The current group index is already returned by the methods described in my previous reply - please check the example below:

var target = $($(".k-scheduler-content td[role=gridcell]")[0]);
var slot = scheduler.slotByElement(target);
 
//result:
Object {
    startDate: Date 2013-06-08 T21:00:00.000 Z,
    endDate: Date 2013-06-09 T21:00:00.000 Z,
    groupIndex: 0,
    element: < td.k-state-border-down> ,
    isDaySlot: true
}

Regards,
Vladimir Iliev
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
Tags
Scheduler
Asked by
AceRoute Dev
Top achievements
Rank 1
Answers by
Vladimir Iliev
Telerik team
AceRoute Dev
Top achievements
Rank 1
Marshall Jones
Top achievements
Rank 1
Share this question
or