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

How to highlight the selected day on page load (or after view change)

3 Answers 176 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
Richard
Top achievements
Rank 1
Richard asked on 29 Mar 2012, 12:51 PM
Hello Telerik Team,
I have a little problem with highlighting the selected day in the month view. I know there is a kb article which describes how to highlight the selected day in the month view.
My problem is, when I use a handler for the TimeSlotCreated event, like

void OTRadScheduler_TimeSlotCreated(object sender, TimeSlotCreatedEventArgs e)
{
   if (e.TimeSlot.Start.Date == OTRadScheduler.SelectedDate)
   {
        e.TimeSlot.CssClass = "rsSelectedSlot";
   }
   else
   {
        // if the actuale date of the time slot is not the selected date, check if the rsSelectedSlot css class is set, if so delete it
        if (string.Compare(e.TimeSlot.CssClass, "rsSelectedSlot") == 0)
        {
            e.TimeSlot.CssClass = "";
        }
    }
}

and the RadScheduler control starts with the month view, the selected date will be displayed correctly (for example with a green background for the Web2.0 skin.

But if I change now to the day view and use the navigation controls in the header to go forward one day and afterwards change back to the month view, at first glance the new selected day will be displayed with the css class above. But if I select now a new day in the month view, then the new day will be displayed with the above css class (which is correct) BUT THE FORMER day which was set to this class after the view change still is displayed with the new css class. So I get two highlighted days, as long as I do not select the former selected day.

As I understand it, if in the month view a day is selected with a single click (inserting of new days only with double clicks), the java script methods of the scheduler control take care of unselecting all days and selecting the new one, i.e. these methods change the css class of the former selected day (tested it with the firefox web debugger). But if the css class of a time slot item is set in the code behind using the handler, this day is not unselected by the java script methods when a new day is selected.

I hope you have some ideas,
Richard.

3 Answers, 1 is accepted

Sort by
0
Plamen
Telerik team
answered on 03 Apr 2012, 08:22 AM
Hello Richard,

 
In this scenario the css class that is used is the same as the inbuilt CSS class in RadScheduler that is added to a  selected time slot. That is why when you click the other slot its color is changed as well. I will recommend you to change the class that you are using to "rsSelectedDate" for example and then the colored slot will be only one.

If you want to change the selected date on click another slot you will have to use the code from the KB that you have already reviewed- How to go to a specific date in Day View by clicking on the date cell in Month View. You just have to skip changing the views and stay on MonthView.

Hope this will be helpful.

Regards,
Plamen Zdravkov
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
Richard
Top achievements
Rank 1
answered on 03 Apr 2012, 03:06 PM
Hello Plamen,
I used the 'rsSelectedSlot' CSS class in my TimeSlotCreated event handler on purpose to get the same background color of the day (in month view) as if clicking this day.

But I now realised that this this day has the 'rsSelectedSlot' css class (the <td> element of the html page has this css class) but the javascript method get_seletedSlots() of the scheduler control returns zero (after switching from day view to month view and setting the css class of the TimeSlot object of the last selected day).

I found the javascript method get_selectedSlots() of the scheduler control. Is there a similar method to set a selected Slot?

The idea is to set one ore more time slots in the view programmatically in javascript and NOT in the server side TimeSlotCreated event handler. Is this possible?

Greetings,
Richard Huber.
0
Richard
Top achievements
Rank 1
answered on 04 Apr 2012, 12:12 PM
Hello Plamen,
I could solve my little problem. And I have to say the error was on my side :-). I used an own ajax request (with my RadAjaxManager) when clicking a day in the month view or a time slot in the week view. But I forgot to include another AjaxSetting configuration with the RadAjaxManager itself as control ID and the RadScheduler control as updated ID. Therefore after clicking a day the ajax request was made but not properly, because of the missing AjaxSettings with the RadAjaxManager as control ID.
Now after including another AjaxSetting all works fine.

Sorry for wasting your time when the error was on my side.

Greetings,
Richard Huber. 
Tags
Scheduler
Asked by
Richard
Top achievements
Rank 1
Answers by
Plamen
Telerik team
Richard
Top achievements
Rank 1
Share this question
or