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

Change date heading CSS in week view

7 Answers 112 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
Rimma
Top achievements
Rank 1
Rimma asked on 12 Feb 2013, 08:13 PM
Hi, I'd like to show the date heading in a different style for today's date in week view.
Is it possible?  I've updated the CSS on the time slot and that only changes the actual timeslots, not the corresponding heading for that day.
Thanks!

7 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 13 Feb 2013, 09:11 AM
Hi Rimma,

Try the following Javascript to style the today's date in week view.

Javascript:
<script type="text/javascript">
function pageLoad() {
    $telerik.$(".rsHorizontalHeaderTable th").each(function (index, item) {
        var childNode = item.childNodes[0];
        if (childNode != null) {
            var today = new Date();
            today.setHours(0); today.setMinutes(0); today.setSeconds(0);
            if (childNode.href != null) {
                var hrefDate = childNode.href.split('#')[1];
                var date = new Date(hrefDate);
                date.setHours(0); date.setMinutes(0); date.setSeconds(0);
                if (date.toDateString() == today.toDateString()) {
                    item.style.backgroundImage = "none";
                    item.style.backgroundColor = "yellow";
                }
            } else {
                var innerText = childNode.innerHTML.trim();
                var date = new Date(innerText);
                date.setHours(0); date.setMinutes(0); date.setSeconds(0);
                if (date.toDateString() == today.toDateString()) {
                    item.style.backgroundImage = "none";
                    item.style.backgroundColor = "yellow";
                }
            }
        }
    });
}
</script>

Thanks,
Princy.
0
Mehmet
Top achievements
Rank 1
answered on 17 Nov 2014, 03:01 AM
Hi,

It does highlight the same day's name for all weeks-months.
So why does it happen?
0
Boyan Dimitrov
Telerik team
answered on 20 Nov 2014, 08:42 AM
Hello,

I would like to clarify that solution provided by Princy highlights the today's date in week view's heading section. It does not highlight the date only in week view and does not highlight in same day for each month. It only colors the today's date this year.

Regards,
Boyan Dimitrov
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Mehmet
Top achievements
Rank 1
answered on 20 Nov 2014, 11:10 PM
What is the solution to just highlight today's date on the current week rather than the all year's today date's name ?
Thank you
0
Boyan Dimitrov
Telerik team
answered on 24 Nov 2014, 01:17 PM
Hello,

I guess that you want to color all time slots for today's date in the week view. You can achieve this by using the RadScheduler OnTimeSlotCreated event and sets custom class for all today's date time slots:
//code behind
protected void RadScheduler1_TimeSlotCreated(object sender, TimeSlotCreatedEventArgs e)
    {
        if (RadScheduler1.SelectedView == SchedulerViewType.WeekView && e.TimeSlot.Start.Date == DateTime.Now.Date)
        {
            e.TimeSlot.CssClass = "todaysDate";
        }
    }

Using css you can set the time slot element background color.

Regards,
Boyan Dimitrov
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Mehmet
Top achievements
Rank 1
answered on 24 Nov 2014, 10:03 PM
Can you provide me a JS code of it?
Thank you
0
Boyan Dimitrov
Telerik team
answered on 26 Nov 2014, 08:39 AM
Hello,

Please find the client-side solution below:
//JavaScript
function pageLoad() {
    var scheduler = $find("<%= RadScheduler1.ClientID %>");
    if (scheduler.get_selectedView() == 1) {
        var timeSlotsDOM = $telerik.$($telerik.$(".rsContentTable tr td"));
        for (var i = 0; i < timeSlotsDOM.length; i++) {
            var DOMElement = timeSlotsDOM[i];
            var date = $find("RadScheduler1").get_activeModel().getTimeSlotFromDomElement(DOMElement).get_startTime().toDateString();          
            var todayDate = new Date().toDateString();
            if (date == todayDate) {
                $telerik.$(DOMElement).addClass("todaysClass");
            }
 
        }
    }
     
}
//css
.todaysClass {
            background-color:red;
        }


Regards,
Boyan Dimitrov
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
Scheduler
Asked by
Rimma
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Mehmet
Top achievements
Rank 1
Boyan Dimitrov
Telerik team
Share this question
or