25 Answers, 1 is accepted
Thank you for the excellent question. You're on the right track - the populating event is exactly what you need. You can add your custom fields like this:
function aptsPopulating(sender, eventArgs)
{
var info = eventArgs.get_schedulerInfo();
info.MyCustomInfo = "Test";
}
In order to read this on the server you need to inherit the SchedulerInfo class:
public class MySchedulerInfo : SchedulerInfo
{
private string _myCustomInfo;
public string MyCustomInfo
{
get
{
return _myCustomInfo;
}
set
{
_myCustomInfo = value;
}
}
}
[WebMethod]
public IEnumerable<AppointmentData> GetAppointments(MySchedulerInfo schedulerInfo)
{
string info = schedulerInfo.MyCustomInfo;
// ...
}
Serialization shouldn't be an issue with most types. Dates are a bit trickier as you need to compensate for the client browser time zone offset, as they are serialized as ticks. We do this in RadScheduler, but for simplicity I recommend you to pass them as strings in a well known format.
Regards,
Tsvetomir Tsonev
the Telerik team
Check out Telerik Trainer , the state of the art learning tool for Telerik products.
As a follow up, I was wondering if you can answer this question
I have the following WebserviceappointmentController classs, shown partially here
public class SchedulerService : ISchedulerService
{
private WebServiceAppointmentController _controller;
private WebServiceAppointmentController Controller
{
get
{
if (_controller == null)
{
_controller =
new WebServiceAppointmentController(new SchedulerServiceProvider());
}
return _controller;
}
}
public IEnumerable<AppointmentData> GetAppointments(MySchedulerInfo schedulerInfo)
{
return Controller.GetAppointments(schedulerInfo);
}
.....
.....
When GetAppointment is called, the call to Controller.GetAppointments correctly takes me to the GetAppointments method of ScheduleServiceProvider which inherits SchedulerProviderBase class. But with in the GetAppointments method of this ScheudleService provider,I cannot see a way to get bavck to MySchedulerInfo and the my custom data in there. If I cannot get to it then I cannot do much becasue all the backend stuff to get appointment data happens in ScehduleService provider based on the MySchedulerInfo data.
I hope you will be able to throw some light on this.
Thanks
Raj
Thank you for the excellent question. It's true that the existing SchedulerProvider interface limits us in our options to pass information to the provider. We are considering improving it, but for the moment there are two options:
1. Use the session to pass parameters:
[WebMethod(EnableSession = true)]
public IEnumerable<AppointmentData> GetAppointments(MySchedulerInfo schedulerInfo)
{
Session["Data"] = schedulerInfo.Data;
return Controller.GetAppointments(schedulerInfo);
}
// Provider code:
int Data = (int) HttpContext.Current.Session["Data"];
2. Instantiate the provider per request and use its public properties to pass parameters.
I hope this helps.
Kind regards,
Tsvetomir Tsonev
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
We still haven't implemented the improvements to the SchedulerProvider abstract base class. The Session and directly referencing the provider instance remain the only two options for passing additional information to the provider.
The GetAppointmentsMethod property only specifies the Web Service method name to be used for retrieving appointments and has no other uses.
Sincerely yours,
Tsvetomir Tsonev
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
I'm not sure if time will allow us to complete these improvements for the Q3 release, as we already have a lot of work in the pipeline. We'll be working on a prototype meanwhile, but for now our primary objective is to get feedback from the community.
Sincerely yours,
Tsvetomir Tsonev
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
This is what I had in mind:
[WebMethod]
public
IEnumerable<AppointmentData> GetAppointments(MySchedulerInfo schedulerInfo)
{
MySchedulerProvider provider =
new
MySchedulerProvider(...);
provider.Property = MySchedulerInfo.Property;
WebServiceAppointmentController controller =
new
WebServiceAppointmentController(provider);
return
controller.GetAppointments(schedulerInfo);
}
You can use your implementation of ISchedulerInfo to pass additional data as described earlier. Then you set a property on the provider to let it know about the additional data.
The drawback is that the provider must be instantiated on each request, while its normally shared between requests.
All the best,
Tsvetomir Tsonev
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
function AppointmentsPopulating(sender, eventArgs) { |
var info = eventArgs.get_schedulerInfo(); |
info.ObjectId = "BEE39F67-3737-4A05-9AA3-DD61D9CCEE77"; //TODO get Object ID from UI |
} |
What about on Insert, update, delete methods? How do I accomplish this when all I have access to in this case is the appointment object which as far as I can tell right now does not expose a scheduler info? Is that right?
function AppointmentWebServiceInserting(sender, eventArgs) { |
//get object Id from UI and pass it along to the scheduler info so I can get at the object Id from the web service |
} |
I will then need to obtain the object Id in the web service
[WebMethod] |
public IEnumerable<AppointmentData> InsertAppointment(OutputControlSchedulerInfo schedulerInfo, AppointmentData appointmentData) |
{ |
if (!string.IsNullOrEmpty(appointmentData.RecurrenceRule)) |
{ |
appointmentData.RecurrenceState = RecurrenceState.Master; |
} |
MyScheduleProvider provider = new MyScheduleProvider(); |
provider.ObjectId = schedulerInfo.ObjectId; |
WebServiceAppointmentController controller = new WebServiceAppointmentController(provider); |
return controller.InsertAppointment(schedulerInfo, appointmentData); |
} |
Does this make sense at all?
EDIT What event gets fired on the client-side when the save button is clicked on the Advanced Form?
Where do I handle that event and pass an object ID to the web service so it can pass that Id onto the provider?
EDIT yeah it seems i do have the scheduler info on the web service insert! very nice.
thanks
Thank you for posting these questions and thus enriching the discussion. It seems you were able to find the answers yourself, but feel free to contact us if you have further questions or concerns.
All the best,
Peter
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
What is the purpose of using this web service appointment controller object in the following code?
MySchedulerProvider provider = new MySchedulerProvider(...);
provider.Property = MySchedulerInfo.Property;
WebServiceAppointmentController controller = new WebServiceAppointmentController(provider);
return controller.GetAppointments(schedulerInfo);
When in this case I coould just as easily call provider.GetAppointments?
What does this technique buy?
The WebServiceAppointmentController.GetAppointments method takes care of filtering only the visible appointments and for expanding recurring series.
It's meant to be a bridge between the provider and the control instance and to encapsulate the logic that links them together.
I hope this helps.
Greetings,
Tsvetomir Tsonev
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Is session the only way to pass back the web page URL that hosts the Scheduler? By the way, I am working in SharePoint environment and the hosting site URL is the most popular parameter to hold on.
I can confirm that at the moment the two options for passing information to the provider are:
1. Transfer information via the Session
2. Instantiate the provider per request and use its public properties to pass parameters
We have plans to improve this by updating the RadScheduler provider interface, but it's unlikely that we'll be able to complete these changes in time for the next release.
All the best,
Tsvetomir Tsonev
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
1) The OnClientAppointmentsPopulating event gets fired even when the Scheduler is doing a WebServices Update/Insert/Delete. So if you are using the same values in each operation, then you can just add the values to the SchedulerInfo object in this event and they will be present during all operations.
2) Even though it's not currently listed in the documentation, you can access the SchedulerInfo in the Web Services Update/Insert/Delete client-side events like this: eventArgs.get_schedulerInfo(). So, if you have different values you want to add for each operation, you can do so in the appropriate client-side event.
-Ryan
I'd like to announce that we've made improvements to the provider interface of RadScheduler that make sending extra data much easier. Read more here: http://blogs.telerik.com/tsvetomirtsonev/posts/10-10-25/radscheduler_for_asp_net_ajax_-_improvements_to_provider_interface_in_q3_2010.aspx
Please feel free to try the Q3 2010 Beta and let us know if you have any comments.
Ryan, thanks for sharing the hints - we're updating the documentation right now and we'll try to make these possibilities clear.
Greetings,
Tsvetomir Tsonev
the Telerik team
When the scheduler needs to render many daily appointments in month view, even though it only displays 2 per day, the total number of appointments can be quite large and unfortunately the scheduler returns and iterates through all though it really needs to only worry about 2 per day.
This causes IE to be unresponsive. Not sure if anyone on your end has started looking at that issue yet.
cheers
Yes, we're working on this problem as well. The official release will be a bit smarter about the extra appointments and will trim them before leaving the web service.
I hope this helps.
Greetings,
Tsvetomir Tsonev
the Telerik team
I've been looking at this thread, and this section in the online documentation:
http://www.telerik.com/help/aspnet-ajax/scheduler-sending-additional-information-to-the-web-service.html
But I'm struggling to make my radscheduler populate from my web service at the moment.
I've got the following in my sheduler control
<WebServiceSettings Path="~/Services/Calendar_Service.asmx" />
And have a javascript function being called with the 'OnClientAppointmentsPopulating', which sets my accountid property :
eventArgs.get_schedulerInfo().AccountID
I've my own SchedulerInfo class:
public
class
MySchedulerInfo : SchedulerInfo
{
public
int
AccountID {
get
;
set
; }
public
MySchedulerInfo(ISchedulerInfo baseInfo,
int
accountid)
:
base
(baseInfo)
{
AccountID = accountid;
}
}
My web service takes an object of this class as a param:
[WebMethod]
public
IEnumerable<AppointmentData> GetAppointments(MySchedulerInfo schedulerInfo)
{
return
Controller.GetAppointments(schedulerInfo);
}
And I have my own custom provider that takes an ISchedulerInfo param with it's 'GetAppointments' method.
However, when I run this, I just get a javascript alert with the following error (twice):
"No parameterless constructor defined for type of 'Classes.MySchedulerInfo'"
I've tried to do this as per the instructions, what am I missing?
This error is self-descriptive: you don't have parameterless constructor in the MySchedulerInfo class. Please add the following constructor and everything will work OK:
public
class
MySchedulerInfo : SchedulerInfo
{
public
int
AccountID {
get
;
set
; }
public
MySchedulerInfo(ISchedulerInfo baseInfo,
int
accountid)
:
base
(baseInfo)
{
AccountID = accountid;
}
public
MySchedulerInfo()
{
}
}
All the best,
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.
http://www.telerik.com/help/aspnet-ajax/scheduler-sending-additional-information-to-the-web-service.html
You are definitely right that the documentation needs improvement. Thank you!
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.
You can refer to this Code Library where are provided all the steps to sent more information to the service. The steps are exactly the same in scenario with WCF service.
Hope this will be helpful.
Plamen
Telerik