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

How to change the background of a timeslot container ?

10 Answers 190 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
Carlos
Top achievements
Rank 1
Carlos asked on 09 Jul 2010, 11:49 PM
Hi I have a problem I need to change the background color of a timeslot container , when i click over it and is not assigned to a appointment ?

How can i do that ,pleasse help me?

10 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 12 Jul 2010, 08:22 AM
Hello Carlos,


You can do it in 'OnClientTimeSlotClick' client side event of RadScheduler.

JavaScript:
<script type="text/javascript">
    function OnClientTimeSlotClick(sender, args) {
        args.get_targetSlot().get_domElement().style.backgroundColor = "silver";
    }
</script>



-Shinu.
0
Carlos
Top achievements
Rank 1
answered on 14 Jul 2010, 09:33 PM
OK ,thanks i got it  !!!!

Now if i want that when i select another timeslot the previously selected return to normal ?
I do something like this but i dont now,not always work sometimes i have 3 timeslot with silver background color.

PreviousSlotXCoordinate_value.value = eventArgs._domEvent.clientX;

PreviousSlotYCoordinate_value.value = eventArgs._domEvent.clientY;

//Get local controls to store the coordinates
var PreviousSlotXCoordinate_value = $get('<%=PreviousSlotXCoordinate.ClientID %>');
var PreviousSlotYCoordinate_value = $get('<%=PreviousSlotYCoordinate.ClientID %>');
  
//Change the bgcolor
eventArgs.get_targetSlot().get_domElement().style.backgroundColor = "Yellow";
  
//if previously selected some timeslot
if (PreviousSlotXCoordinate_value.value != ''
{
sender._getCellFromCoordinates(parseInt(PreviousSlotXCoordinate_value.value), parseInt(PreviousSlotYCoordinate_value.value)).bgColor = ''
}
//I store the selected row coordinates to check later
PreviousSlotXCoordinate_value.value = eventArgs._domEvent.clientX;
PreviousSlotYCoordinate_value.value = eventArgs._domEvent.clientY;
0
Veronica
Telerik team
answered on 21 Jul 2010, 04:43 PM
Hi Carlos,

One simple solution is to iterate through all timeSlots and clear the background in the OnClientTimeSlotClick event via jQuery. After that you can simply set the backround to the last clicked timeSlot as you did before. Here's the code:

function OnClientTimeSlotClick(sender, args) {
            var $ = $telerik.$;
            $(".rsWrap").each(function(i) {
                this.style.backgroundColor = "white";
            });
            args.get_targetSlot().get_domElement().style.backgroundColor = "silver";
        }

Hope this helps.

Kind regards,
Veronica Milcheva
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Carlos
Top achievements
Rank 1
answered on 23 Jul 2010, 06:21 PM
Hi veronica ,thanks for your answer unfortunately the code don't work,the scheduler always maintain 2 or more timeslot´s with color "yellow" and i need only one to be selected and identified with that color.

the attachment is an image of what my scheduler do.

Thanks
0
Accepted
Veronica
Telerik team
answered on 29 Jul 2010, 02:09 PM
Hi Carlos,

The example code worked but only for MonthView. The reason not to work in other views is that .rsWrap class does not renders when you don't have appointments.

So, here's the modificated code:

function OnClientTimeSlotClick(sender, args) {
            var $ = $telerik.$;
            $(".rsContentTable .rsWrap, .rsContentTable td").each(function(i) {
                this.style.backgroundColor = "white";
            });
            args.get_targetSlot().get_domElement().style.backgroundColor = "yellow";
        }

Hope this helps.

All the best,
Veronica Milcheva
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Carlos
Top achievements
Rank 1
answered on 15 Jun 2011, 05:31 PM
Hello, i apply this solution and works great, but now i have a new question, i block some timeslot´s setting this style from codebehind in the TimeSlot_created event :

ASPX.

.Disabled

{

 

background: gray

;

 

 

 

 

cursor: not-allowed

;

 

 

}

 

 

 

.Disabled.rsAptCreate

 

 

{

 

background: gray !important

;

 

 

}

VB.

 

e.TimeSlot.CssClass =

"Disabled"

when i run the function that put all timeslots backgrounds to white include the timeslots that are blocked and i want to mantain the gray color for the blocked timeslots.

I include a attachment with an image of how look my Schedule went a timeslot is blocked.

What can i do ? ,thanks

0
Veronica
Telerik team
answered on 17 Jun 2011, 08:00 AM
Hi Carlos,

Please take a look at this Knowledge Base article and let me know if it helps.

Best wishes,
Veronica Milcheva
the Telerik team

Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

0
NEX
Top achievements
Rank 1
answered on 12 Apr 2012, 04:42 AM
args.get_targetSlot().get_domElement().style.backgroundColor = "silver";

This is not working with build 2011.2.915.35 in the Week view.
0
Princy
Top achievements
Rank 2
answered on 12 Apr 2012, 07:18 AM
Hi Alfred,

I tried in to reproduce the problem in 2011, 2, 915, 35 version, but no avail. Please take a look into the following code which worked as expected for me.

ASPX:
<telerik:RadScheduler ID="RadScheduler2" runat="server"   DataEndField="End"  DataKeyField="ID" OnClientTimeSlotClick="OnClientTimeSlotClick"  DataRecurrenceField="RecurrenceRule" DataRecurrenceParentKeyField="RecurranceParentID" DataReminderField="Reminder" DataSourceID="SqlDataSource1" DataStartField="Start" DataSubjectField="Subject" >
</telerik:RadScheduler>

JS:
<script type="text/javascript">
 function OnClientTimeSlotClick(sender, args)
  {
        args.get_targetSlot().get_domElement().style.backgroundColor = "silver";
  }
</script>

Please elaborate your scenario if it doesn't helps.

Thanks,
Princy.
0
NEX
Top achievements
Rank 1
answered on 13 Apr 2012, 05:35 PM
Could not get your code to work but I did get this work. Changing the style:

timeSlot.get_domElement().className = "selected";
Tags
Scheduler
Asked by
Carlos
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Carlos
Top achievements
Rank 1
Veronica
Telerik team
NEX
Top achievements
Rank 1
Princy
Top achievements
Rank 2
Share this question
or