Hello.
In the web application I have been developing, there is a web page page that uses the RadScheduler component with web service binding.
The RadScheduler component displays appointments grouped by resources.
Since the resources are loaded by a stored procedure that requires input parameters, class SchedulerInfo has been extended:
public
class
SchedulerInfoExt : SchedulerInfo
{
public
Int16 ClubId {
get
;
set
; }
public
String ResourceType {
get
;
set
; }
public
String MembershipNumber {
get
;
set
; }
public
String InsertResult {
get
;
set
; }
public
SchedulerInfoExt(ISchedulerInfo baseInfo, Int16 clubId, String resourceType, String membershipNumber) :
base
(baseInfo)
{
ClubId = clubId;
ResourceType = resourceType;
MembershipNumber = membershipNumber;
InsertResult =
""
;
}
public
SchedulerInfoExt()
{
}
}
In the web page, a RadDock component is used to implement a form that allows users to create appointments.
In the Data Provider class, the Insert method validates the business rules and creates the appointment. The scheduler info property InsertResult is set by the Insert method, indicating if the insertion was successful, if there was an error or if there was a violation of the business rules.
On the client side, function AppointmentsPopulated, associated with event OnClientAppointmentsPopulated, is supposed to display a message based on the content of the scheduler info property InsertResult, informing the user if the appointment was created or if there was an error.
Is it possible to access the scheduler info property InsertResult from the client side function AppointmentsPopulated?
Thank you in advance.
Paulo
9 Answers, 1 is accepted
You can assign the scheduler info property InsertResult in OnClientAppointmentsPopulating instead of in OnClientAppointmentsPopulated as it is done in the WebService demo.
Hope this will be helpful.
Plamen Zdravkov
the Telerik team

Hello, Plamen.
Thank you for your reply.
As I mentioned in the first post, scheduler info property InsertResult is set by the Insert method.
Unfortunately, the method you suggested, OnClientAppointmentsPopulating, is executed before Insert.
Since OnClientAppointmentsPopulated is executed after Insert, that's where I tried to retrieve the value of InsertResult. Isn't it possible to access the scheduler info properties from there?
Thank you again.
Paulo
Have you considered using the Returning extra data from the Web Service help topic to achieve the desired functionality?
Plamen Zdravkov
the Telerik team

Thank you for your suggestion.
In order to implement what the help topic suggests, I have implemented the following changes in my application:
1) Creation of class SchedulerResult
public
class
SchedulerResult : SchedulerOperationResult<AppointmentData>
{
public
String InsertResult {
get
;
set
; }
}
2) In the Data Provider class, I have changed the return type of method Insert from
public
override
void
Insert(ISchedulerInfo schedulerInfo, Appointment appointmentToInsert)
public
override
SchedulerResult Insert(ISchedulerInfo schedulerInfo, Appointment appointmentToInsert)
This way, the result of the insertion (stored in the local variable insResult) is assigned to property InsertResult:
SchedulerResult result =
new
SchedulerResult();
result.InsertResult = insResult;
return
result;
The compiler has not "approved" these changes though:
'Scheduling.PersonalTraining_PrivateTraining_DataProvider.Insert(Telerik.Web.UI.ISchedulerInfo, Telerik.Web.UI.Appointment)': return type must be 'void' to match overridden member 'Telerik.Web.UI.SchedulerProviderBase.Insert(Telerik.Web.UI.ISchedulerInfo, Telerik.Web.UI.Appointment)'
I would appreciate whether you could help me address this issue.
Thank you.
Paulo
Would you please try to overrider the WebMethod in the SchedulerWebService.cs:
[WebMethod]
public
IEnumerable<AppointmentData> InsertAppointment(MySchedulerInfo schedulerInfo, AppointmentData appointmentData)
{
return
Controller.InsertAppointment(schedulerInfo, appointmentData);
}
Hope this will be helpful.
Regards,
Plamen Zdravkov
the Telerik team

In the Web Service class, method InsertAppointment has been changed from
public
IEnumerable<AppointmentData> InsertAppointment(SchedulerInfoExt schedulerInfo, AppointmentData appointmentData)
{
return
Controller.InsertAppointment(schedulerInfo, appointmentData);
}
to
public
SchedulerResult InsertAppointment(SchedulerInfoExt schedulerInfo, AppointmentData appointmentData)
{
return
(SchedulerResult)Controller.InsertAppointment(schedulerInfo, appointmentData);
}
The compiler has issued the same error though:
'Scheduling.PersonalTraining_PrivateTraining_DataProvider.Insert(Telerik.Web.UI.ISchedulerInfo, Telerik.Web.UI.Appointment)': return type must be 'void' to match overridden member 'Telerik.Web.UI.SchedulerProviderBase.Insert(Telerik.Web.UI.ISchedulerInfo, Telerik.Web.UI.Appointment)'
I have also tried
public
override
SchedulerResult InsertAppointment(SchedulerInfoExt schedulerInfo, AppointmentData appointmentData)
{
return
(SchedulerResult)Controller.InsertAppointment(schedulerInfo, appointmentData);
}
- 'Scheduling.PersonalTraining_PrivateTraining_WS.InsertAppointment(Scheduling.SchedulerInfoExt, Telerik.Web.UI.AppointmentData)': no suitable method found to override
- 'Scheduling.PersonalTraining_PrivateTraining_DataProvider.Insert(Telerik.Web.UI.ISchedulerInfo, Telerik.Web.UI.Appointment)': return type must be 'void' to match overridden member 'Telerik.Web.UI.SchedulerProviderBase.Insert(Telerik.Web.UI.ISchedulerInfo, Telerik.Web.UI.Appointment)'
What could you suggest to solve the problem?
Thank you again.
Paulo
I have attached a sample web page where the Insert WebMethod is overriden as in the help topic that was lined before.
Hope this will be helpful.
All the best,
the Telerik team

Thank you very much for your valuable feedback. It works!
I just have one more question before considering the issue solved.
After adding the appointment and displaying the results on the client side via function alert, I noticed that RadScheduler was refreshed, but no appointments were displayed, neither the existing ones nor the new one.
In order to solve the problem, I added a RadScheduler.rebind() call:
function
RequestSuccess(s, e)
{
if
(document.getElementById(
"insert"
).value ==
"InsertProcessed"
)
{
// refreshing RadScheduler
$find(
"<%= RadScheduler1.ClientID %>"
).rebind();
alert(
"result: "
+ e.get_result().InsertResult);
document.getElementById(
"insert"
).value =
""
;
// closing the RadDock
$find(
"<%= RadDockInsert.ClientID %>"
).set_closed(
true
);
}
}
Before adding this logic to capture and display the results of the web service call, RadScheduler was being refreshed automatically and all appointments were displayed accordingly (the existing ones and the new one).
Why is this happenning now?
Thank you again for your assistance.
Paulo
I have inspected the issue with the project I attached in the previous post, but every time the appointments were displayed properly just after the alert is closed. Here you can see a video of my test.
If you still observe the issue please let me know how should I change the ExtraDate project in order to observe the same behavior.
Plamen Zdravkov
the Telerik team