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

Rebind (web service) does not call TimeSlotCreated

9 Answers 125 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
SolutionStream
Top achievements
Rank 1
SolutionStream asked on 09 Apr 2010, 12:13 AM
Rebind (web service) does not call TimeSlotCreated.

I know this might be as designed, but is there a way for me to trigger the scheduler to rebuild the timeslots?

9 Answers, 1 is accepted

Sort by
0
T. Tsonev
Telerik team
answered on 09 Apr 2010, 07:53 AM
Hello,

I can confirm that this is true. The rebind operation is carried entirely client-side and the time slots are, as of this moment, created on the server. You can either use jQuery to enumerate the cells and apply styles, etc. or postback to the server to use the server-side event.

I hope this helps.

Sincerely yours,
Tsvetomir Tsonev
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
Jose Granja
Top achievements
Rank 1
answered on 08 Dec 2010, 06:25 PM
Could you tell what would be a good approach to do that? Is there any helper function which I can use to call the web service with a custom method?

For example webservice.callMethod(getTimeSlots()) ? How can I loop throught all the time slots? Would that make the scheduler really slow?

The timeslots are crucial for my implementacion of the radscheduler

regards and excuse my bad english,

jose
0
Nikolay Tsenkov
Telerik team
answered on 15 Dec 2010, 11:46 AM
Hi Jose Granja,

Could you, please, explain in a bit more detail what exactly do you try to achieve?
I am sure that we will be able to suggest something!


Regards,
Nikolay Tsenkov
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
Jose Granja
Top achievements
Rank 1
answered on 15 Dec 2010, 11:55 AM
Hi, thanks for the reply.

Basically the users using my diary have previously set up an availibility times (it can be different every week) where the appointments can be booked. In order to show the availibility times I paint the background in blue. We were working with the server side binding but it's so slow that we're changing to web service binding. Before I used to color de background catching the onTimeSlotCreated event and I was doing the following:

protected void RadScheduler1_TimeSlotCreated(object sender, Telerik.Web.UI.TimeSlotCreatedEventArgs e)
        {
            foreach (Telerik.Web.UI.Appointment Appointment in _ListBackgroundAppointments)
            {
                if (DateTime.Compare(Appointment.Start, e.TimeSlot.Start) <= 0 && DateTime.Compare(Appointment.End, e.TimeSlot.Start) > 0
                        && DateTime.Compare(Appointment.Start, e.TimeSlot.End) < 0 && DateTime.Compare(Appointment.End, e.TimeSlot.End) >= 0)
                {
                    foreach (Resource Resource in Appointment.Resources)
                    {
                        if (e.TimeSlot.Resource != null && Resource.Key.ToString().Equals(e.TimeSlot.Resource.Key.ToString()))
                        {
                            e.TimeSlot.Resource.Attributes["IDAvailablePeriod"] = e.TimeSlot.Resource.Attributes["IDAvailablePeriod"] + "," + Convert.ToString(Appointment.ID);
                            e.TimeSlot.CssClass = Resource.CssClass;
                            return;
                        }
                    }
 
                }
            }
        }

Now I supose I have to use the onClientDataBound client-side event, Am I wrong? I have to query all availibility periods throught an AJAX call as well right? I just wonder how I could get all the time slots from the client object and how was the best way to do it.

Could I add another method in the webservice and use the client to call it? That way I would add the availibility users methods there and everything would be more tidy :)
0
Nikolay Tsenkov
Telerik team
answered on 16 Dec 2010, 12:35 PM
Hi Jose Granja,

Currently there is no easy and trivial way to get all timeSlots.
We are going to consider such a functionality and will let you know our decision.
In any case we will try to provide you at least with a workaround for your scenario.


Regards,
Nikolay Tsenkov
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
Jose Granja
Top achievements
Rank 1
answered on 16 Dec 2010, 01:19 PM
Thank you very much for you post! If you could tell me a workarround that would be great! The speed is crucial in our project that why we were forced to move to Web Service and we have a release coming in the next month!

please let me know when you find a solution.

regards,

jose
0
Nikolay Tsenkov
Telerik team
answered on 21 Dec 2010, 04:17 PM
Hi Jose Granja,

I have prepared a workaround for styling the TimeSlots on the client-side. I have modified the ExactTimeRendering demo.
Here it goes:
1. Markup:
<telerik:RadScheduler runat="server" ID="RadScheduler1" EnableExactTimeRendering="true"
    SelectedView="DayView" SelectedDate="2009-02-02" DayStartTime="07:00" FirstDayOfWeek="Monday"
    LastDayOfWeek="Friday" GroupBy="Calendar" GroupingDirection="Horizontal" OnClientAppointmentsPopulated="onClientAppointmentsPopulated"
    <TimelineView GroupBy="Calendar" GroupingDirection="Vertical" SlotDuration="00:30:00" NumberOfSlots="20" />
    <WebServiceSettings Path="SchedulerWebService.asmx" ResourcePopulationMode="ServerSide" />
        ...
</telerik:RadScheduler>
2. JavaScript:
function onClientAppointmentsPopulated(sender, args)
{
    var $ = $telerik.$;
 
    if (sender.get_selectedView() == Telerik.Web.UI.SchedulerViewType.TimelineView)
        $("> tbody > tr > td", $(".rsAllDayTable", sender.get_element())[0]).addClass("rsTimeSlot");
    else
    {
        $("> tbody > tr > td", $(".rsContentTable", sender.get_element())[0]).addClass("rsTimeSlot");
        if (sender.get_selectedView() == Telerik.Web.UI.SchedulerViewType.MonthView)
        {
            var visibleViewsCount = $(".rsContentTable", sender.get_element()).length - $(".rsContentTable : hidden", sender.get_element()).length;
            for (var i = 1; i < visibleViewsCount; i++)
                $("> tbody > tr > td", $(".rsContentTable", sender.get_element())[i]).addClass("rsTimeSlot");
        }
    }
}

I have used a ResourceGrouped example because it's more complex to workaround.

I hope this will be helpful for you!


Regards,
Nikolay Tsenkov
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
Jose Granja
Top achievements
Rank 1
answered on 21 Dec 2010, 05:11 PM
Hi! thanks for the tip!

the bit of code that I need is this one:

$("> tbody > tr > td", $(".rsContentTable", sender.get_element())[0]).addClass("rsTimeSlot");

I should loop throught all the elements and now what time they represent. However I've been looking at the array of objects that this call returns me and I'm not able to work out what is the time of each slot and the resource binded to it!

could you help me out with that? 

thank you in advance,

regards,

jose
0
Peter
Telerik team
answered on 24 Dec 2010, 03:05 PM
Hello Jose,

Please, try the following code which loops through all time slot objects when RadScheduler is bound to a Web Service and sets different styles for time slots in the past.
<script type="text/javascript">        
       function OnClientDataBound(sender) { 
           var $ = $telerik.$;           
           var now = new Date(); 
            $(".rsAllDayTable:visible td", sender.get_element()).each(function (i) { 
               var currentTimeSlot = sender.get_activeModel().getTimeSlotFromDomElement($(this).get(0)); 
                $(this).css("background", " ");  
               if (currentTimeSlot.get_startTime() < now)                   
                      $(this).css("background", "silver");              
           }); 
           $(".rsContentTable:visible td", sender.get_element()).each(function (i) { 
               var currentTimeSlot = sender.get_activeModel().getTimeSlotFromDomElement($(this).get(0)); 
                $(this).css("background", " ");  
               if (currentTimeSlot.get_startTime() < now)                   
                      $(this).css("background", "silver");              
           }); 
       
   </script> 
   <telerik:RadScheduler ID="RadScheduler1" runat="server" OnClientDataBound="OnClientDataBound"
       GroupBy="User"
       <WebServiceSettings Path="SchedulerWebService.asmx" ResourcePopulationMode="ServerSide" /> 
   </telerik:RadScheduler>

Please, give it a try and let us know if everything works as expected.

All the best,
Peter
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.
Tags
Scheduler
Asked by
SolutionStream
Top achievements
Rank 1
Answers by
T. Tsonev
Telerik team
Jose Granja
Top achievements
Rank 1
Nikolay Tsenkov
Telerik team
Peter
Telerik team
Share this question
or