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

get Appointment by id

7 Answers 295 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
piotre6
Top achievements
Rank 1
piotre6 asked on 03 Aug 2011, 11:51 AM
Is it possible to get appointment (needed for editAppointment function) by id on client side?
I have tried to use  scheduler.get_appointments(), unfortunately it only shows appointments oc current view.

7 Answers, 1 is accepted

Sort by
0
Peter
Telerik team
answered on 03 Aug 2011, 03:46 PM
Hi Piotre6,

Indeed, you can only access appointments that are rendered (fall in the visible range). Then you could use-

scheduler.get_appointments().findByID(56).get_subject()


Greetings, 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.

0
piotre6
Top achievements
Rank 1
answered on 03 Aug 2011, 04:35 PM

I have followed the instruction to create dbschedulerprovider and webservice. I 'm trying to consume webservice with following code:

$.ajax({
    type: "POST",
    url: "GuaranteeModule/GuaranteeSchedulerWebService.asmx/GetAppointments",
    contentType: "application/json; charset=utf-8"
    dataType: "json",
    data: "{'schedulerInfo':{}}",
    success: function(msg) {
        AjaxSucceeded(msg);
    },
    error: AjaxFailed
});

While debugging on server side everything seems to be fine, unfortunately on client side I receive following error:
--
The added or subtracted value results in an un-representable DateTime.\r\nParameter name: t","StackTrace":"   at System.DateTime.op_Subtraction(DateTime d, TimeSpan t)\r\n   at Telerik.Web.UI.Scheduling.AppointmentController.ExpandRecurrence(Appointment parent, DateTime rangeStart, DateTime rangeEnd)\r\n   at Telerik.Web.UI.Scheduling.AppointmentController.AddAppointmentAndExpand(Appointment appointment, DateTime rangeStart, DateTime rangeEnd)\r\n   at Telerik.Web.UI.WebServiceAppointmentController.PopulateAppointments(ISchedulerInfo schedulerInfo)\r\n   at Telerik.Web.UI.WebServiceAppointmentController.\u003cGetAppointments\u003ed__0`1.MoveNext()\r\n   at System.Web.Script.Serialization.JavaScriptSerializer.SerializeEnumerable(IEnumerable enumerable, StringBuilder sb, Int32 depth, Hashtable objectsInUse, SerializationFormat serializationFormat)\r\n   at System.Web.Script.Serialization.JavaScriptSerializer.SerializeValueInternal(Object o, StringBuilder sb, Int32 depth, Hashtable objectsInUse, SerializationFormat serializationFormat)\r\n   at System.Web.Script.Serialization.JavaScriptSerializer.SerializeValue(Object o, StringBuilder sb, Int32 depth, Hashtable objectsInUse, SerializationFormat serializationFormat)\r\n   at System.Web.Script.Serialization.JavaScriptSerializer.Serialize(Object obj, StringBuilder output, SerializationFormat serializationFormat)\r\n   at System.Web.Script.Serialization.JavaScriptSerializer.Serialize(Object obj, SerializationFormat serializationFormat)\r\n   at System.Web.Script.Services.RestHandler.InvokeMethod(HttpContext context, WebServiceMethodData methodData, IDictionary`2 rawParams)\r\n   at System.Web.Script.Services.RestHandler.ExecuteWebServiceCall(HttpContext context, WebServiceMethodData methodData)","ExceptionType":"System.ArgumentOutOfRangeException
--
0
Peter
Telerik team
answered on 04 Aug 2011, 10:54 AM
Hello Piotre6,

I haven't tested this way of binding RadScheduler to a web service to be honest. I wonder if there is a reason why you cannot use the approach from the online demo and set:

    <WebServiceSettings Path="SchedulerWebService.asmx" ResourcePopulationMode="ServerSide" />

Attached is also a working demo for reference.

You are welcome to open a support ticket and send us a sample of your implementation so we can test it locally.


Kind regards, 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.

0
piotre6
Top achievements
Rank 1
answered on 04 Aug 2011, 11:39 AM

On my page I have radgrid that displays all appointments and radscheduler with defaultview=timeline to present current week appointments and deal with reminders. I use radscheduler's advanced template to edit appointments.
I want be able to edit appointment when double clicked on grids row:

function onGridRowDblClick(sender, eventArgs)
{
    var scheduler = $find('<%= RadScheduler.ClientID %>');
    var warrantyId = eventArgs.getDataKeyValue("WarrantyId");
    var appointments = scheduler.get_appointments();
    var appointment = appointments.findByID(warrantyId);
    if(appointment != undefined)
    {
        scheduler.editAppointment(appointment, true);
    }
    else 
    {
        createNewAppointment();
    }
}

My problem is that get_appointments() returns only appointments that are in current scheduler view. When I double click on appointment that is not shown on in scheduler appointments.findByID(warrantyId) returns null.
0
Peter
Telerik team
answered on 05 Aug 2011, 10:55 AM
Hello Piotre6,

Yes, this is indeed how th findById method works. As a workaround, I suggest you navigate to the date of the appointment with scheduler.set_selectedDate and handle RadScheduler's OnClientDataBound to find the appointment by id. Here is a sample code:

function onGridRowDblClick() {
 
           var scheduler = $find('<%= RadScheduler1.ClientID %>');
 
           //Here you should be able to pull the values of
           //the Start time and ID of the appointment from the grid event
           appId = "9";
           scheduler.set_selectedDate(new Date());
 
 
       }
       function OnClientDataBound(sender, args) {
           if (appId != null) {
               var scheduler = sender;
               var appointments = scheduler.get_appointments();
               var appointment = appointments.findByID(appId);
 
               if (appointment != null) {
                   scheduler.editAppointment(appointment, true);
               }
               appId = null;
           }
       }
       * * * 
 
 
 <telerik:RadScheduler ID="RadScheduler1" runat="server" OnClientDataBound="OnClientDataBound" .../>


Best wishes,
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.

0
piotre6
Top achievements
Rank 1
answered on 10 Aug 2011, 07:19 AM
I have replaced new Date() with new Date(stringStartDateFromGrid). Date seems to be ok.
After scheduler.set_selectedDate(new Date(stringStartDateFromGrid)) nothing happens.

No matter if I put new Date() or new Date(stringStartDateFromGrid) OnClientDataBound never occurs
0
Peter
Telerik team
answered on 15 Aug 2011, 02:00 PM
Hello Piotre6,

I wasn't able to replicate the problem with the file you sent. We can probably be able to pinpoint the issue if you send us a working sample which we can run without modifications.


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
piotre6
Top achievements
Rank 1
Answers by
Peter
Telerik team
piotre6
Top achievements
Rank 1
Share this question
or