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

Binding service insert and delete with custom form

1 Answer 44 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
Gaurav
Top achievements
Rank 1
Gaurav asked on 23 May 2013, 05:37 PM
Hi,
     I am using Advance Insert and Edit template  in mvc 4 and i want to insert and edit the data into database though webservice on server side.But the Appointment Save and insert button is not working in the custom form.
Please respond as soon as possible.

My code File is like this:-

 <telerik:radscheduler runat="server" id="Scheduler" tooltip="" starteditinginadvancedform="true"
            startinsertinginadvancedform="true" minutesperrow="15" timelabelrowspan="1" hourspaneltimeformat="h:mm tt"
            showfulltime="true" numberofhoveredrows="1" enabledescriptionfield="true" appointmentstylemode="Default"
            selectedview="WeekView" onclientformcreated="OnClientFormCreated" onclientappointmentinserting="OnClientAppointmentInserting"
            onclientappointmentspopulating="OnClientAppointmentsPopulating" onclientappointmentwebserviceinserting="OnClientAppointmentWebServiceInserting"
            onclientdatabound="onSchedulerDataBound" onclientappointmentdoubleclick="hideTooltip"
            onclientappointmentclick="OnClientAppointmentClick" onclientappointmentcontextmenu="appointmentContextMenu"
            onclientappointmentcontextmenuitemclicked="appointmentContextMenuItemClicked"
            advancedform-modal="true">
            <AdvancedForm Modal="true" />
            <AdvancedEditTemplate>
   <div class="rsAdvancedEdit rsAdvancedModal" style="position: relative">
       <div class="rsModalBgTopLeft">
       </div>
       <div class="rsModalBgTopRight">
       </div>
       <div class="rsModalBgBottomLeft">
       </div>
       <div class="rsModalBgBottomRight">
       </div>     
       <div class="rsAdvTitle">          
           <h1 class="rsAdvInnerTitle">
               <%# Container.Appointment.Owner.Localization.AdvancedEditAppointment %></h1>
           <asp:LinkButton runat="server" ID="LinkButton1" CssClass="rsAdvEditClose"
               CommandName="Cancel" CausesValidation="false" ToolTip='<%# Container.Appointment.Owner.Localization.AdvancedClose %>'>
<%# Container.Appointment.Owner.Localization.AdvancedClose%>
           </asp:LinkButton>
       </div>
       <div class="rsAdvContentWrapper">
           <telerik:RadTextBox ID="SubjectTextBox" runat="server" Text='<%# Bind("Subject") %>'
               Label='<%# Container.Appointment.Owner.Localization.AdvancedSubject%>'>
           </telerik:RadTextBox>
           <p>
               Custom content here...
           </p>
           <asp:Panel runat="server" ID="Panel1" CssClass="rsAdvancedSubmitArea">
               <div class="rsAdvButtonWrapper">
                   <asp:LinkButton CommandName="Update" runat="server" ID="LinkButton2" CssClass="rsAdvEditSave">
<span><%# Container.Appointment.Owner.Localization.Save%></span>
                   </asp:LinkButton>
                   <asp:LinkButton runat="server" ID="LinkButton3" CssClass="rsAdvEditCancel" CommandName="Cancel"
                       CausesValidation="false">
<span><%# Container.Appointment.Owner.Localization.Cancel%></span>
                   </asp:LinkButton>
               </div>
           </asp:Panel>
       </div>
   </div>
</AdvancedEditTemplate>
 <AdvancedInsertTemplate>
   <div class="rsAdvancedEdit rsAdvancedModal" style="position: relative">
       <div class="rsModalBgTopLeft">
       </div>
       <div class="rsModalBgTopRight">
       </div>
       <div class="rsModalBgBottomLeft">
       </div>
       <div class="rsModalBgBottomRight">
       </div>     
       <div class="rsAdvTitle">          
           <h1 class="rsAdvInnerTitle">
               <%# Container.Appointment.Owner.Localization.AdvancedNewAppointment %></h1>
           <asp:LinkButton runat="server" ID="AdvancedEditCloseButton" CssClass="rsAdvEditClose"
               CommandName="Cancel" CausesValidation="false" ToolTip='<%# Container.Appointment.Owner.Localization.AdvancedClose %>'>
<%# Container.Appointment.Owner.Localization.AdvancedClose%>
           </asp:LinkButton>
       </div>
        <div class="rsAdvContentWrapper">
           <telerik:RadTextBox ID="SubjectTextBox" Width="100%" runat="server" Text='<%# Bind("Subject") %>' 
               Label='<%# Container.Appointment.Owner.Localization.AdvancedSubject%>'>
           </telerik:RadTextBox>
           <p>
               Custom content here...
           </p>
           <asp:Panel runat="server" ID="ButtonsPanel" CssClass="rsAdvancedSubmitArea">
               <div class="rsAdvButtonWrapper">
                   <asp:LinkButton CommandName="Update" runat="server" ID="UpdateButton" CssClass="rsAdvEditSave">
<span><%# Container.Appointment.Owner.Localization.Save%></span>
                   </asp:LinkButton>
                   <asp:LinkButton runat="server" ID="CancelButton" CssClass="rsAdvEditCancel" CommandName="Cancel"
                       CausesValidation="false">
<span><%# Container.Appointment.Owner.Localization.Cancel%></span>
                   </asp:LinkButton>
               </div>
           </asp:Panel>
       </div>
   </div>
</AdvancedInsertTemplate>
  <AppointmentContextMenus>
                    <telerik:RadSchedulerContextMenu runat="server" ID="SchedulerAppointmentContextMenu">
                        <Items>
                            <telerik:RadMenuItem Text="Check In" Value="IN">
                            </telerik:RadMenuItem>
                            <telerik:RadMenuItem IsSeparator="True">
                            </telerik:RadMenuItem>
                            <telerik:RadMenuItem Text="Check Out" Value="OUT">
                            </telerik:RadMenuItem>
                             <telerik:RadMenuItem IsSeparator="True">
                            </telerik:RadMenuItem>
                            <telerik:RadMenuItem Text="No Show" Value="NS">
                            </telerik:RadMenuItem>
                        </Items>
                    </telerik:RadSchedulerContextMenu>
            </AppointmentContextMenus>
            <WebServiceSettings Path="../../AppointmentWebService.asmx"/>
              <ResourceStyles>
                    <telerik:ResourceStyleMapping Type="Appointment Type" Text="New Consultant" BackColor="skyBlue" />
                    <telerik:ResourceStyleMapping Type="Appointment Type" Text="Surgery" BackColor="Orange" />
                    <telerik:ResourceStyleMapping Type="Appointment Type" Text="Follow Up" BackColor="Green" />
                    <telerik:ResourceStyleMapping Type="Status" Text="No Show"  BorderColor="Black" />
                    <telerik:ResourceStyleMapping Type="Status" Text="In"  BorderColor="Cyan" />
                    <telerik:ResourceStyleMapping Type="Status" Text="Out"  BorderColor="DarkRed" />

              </ResourceStyles>
</telerik:radscheduler>

1 Answer, 1 is accepted

Sort by
0
Plamen
Telerik team
answered on 28 May 2013, 11:40 AM
Hello Gaurav,

 
The code that you are using is relying on server code that is not applicable in case of Web service binding. In this case I will recommend you to us RadButton and its client clicked event to insert or update appointments as it is explained in this documentation article for example.
Here is a sample code that I changed to make such Insert template work:

<asp:Panel runat="server" ID="ButtonsPanel" CssClass="rsAdvancedSubmitArea">
                            <div class="rsAdvButtonWrapper">
                                <telerik:RadButton CommandName="Update" runat="server" ID="UpdateButton" Text="Save"
                                     AutoPostBack="false" OnClientClicked="OnClientClicked" CssClass="rsAdvEditSave">
                                </telerik:RadButton>
                                <telerik:RadButton runat="server" ID="CancelButton" OnClientClicked="OnClientClickedCancel" CssClass="rsAdvEditCancel"
                                     AutoPostBack="false"  CommandName="Cancel" Text="Cancel"
                                    CausesValidation="false">
                                </telerik:RadButton>
                            </div>
function OnClientClicked(sender, args) {
          
          var scheduler = $find('<%=RadScheduler1.ClientID %>');
          var newAppointment = new Telerik.Web.UI.SchedulerAppointment();
 
          var startTime = new Date();
 
          var endTime = new Date(startTime);
          endTime.setMinutes(endTime.getMinutes() + 45);
 
          newAppointment.set_start(startTime);
          newAppointment.set_end(endTime);
          newAppointment.set_subject("Manually Inserted Appointment");
 
          scheduler.insertAppointment(newAppointment);
          scheduler.hideAdvancedForm();
      }
 
 
          function OnClientClickedCancel(sender, args) {
              var scheduler = $find('<%=RadScheduler1.ClientID %>');
              scheduler.hideAdvancedForm();
          }

Hope this will be helpful.Regards,
Plamen
Telerik
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
Scheduler
Asked by
Gaurav
Top achievements
Rank 1
Answers by
Plamen
Telerik team
Share this question
or