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

Appointment DoubleClick Event

6 Answers 278 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
TT
Top achievements
Rank 1
TT asked on 24 Jul 2012, 12:55 PM
Hi, i want to show the contextmenu when i doubleclick on an Appointment, is it possible?

6 Answers, 1 is accepted

Sort by
0
Peter
Telerik team
answered on 26 Jul 2012, 03:38 PM
Hello,

Here is one possible solution:
<script type="text/javascript">
 
      function pageLoad() {
 
          var $ = $telerik.$;
          var scheduler = $find('<%=RadScheduler1.ClientID %>');
          scheduler.get_appointments().forEach(function myfunction(apt) {
              $(apt.get_element()).dblclick(function (e) {
                  var contextMenu = apt.get_contextMenu();
                  contextMenu.show(e);
 
 
              });
          });
      }
   
  </script>
  <telerik:RadScheduler ID="RadScheduler1" runat="server">
      <AppointmentContextMenuSettings EnableDefault="true" />
  </telerik:RadScheduler>


Kind regards,
Peter
the Telerik team
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.
0
TT
Top achievements
Rank 1
answered on 27 Jul 2012, 07:38 AM
thank you, it works!
now i have this problem: when i open the edit form by clicking in the contextmenu (RadScheduler1.ShowAdvancedEditForm(RadScheduler1.Appointments.FindByID(e.Appointment.ID))) two edit forms appear, one is the form i have designed in the radDock and one is the default advanced form.

here is my code:

<telerik:RadScriptBlock runat="server" ID="RadScriptBlock1">
        <script type="text/javascript">
            function openForm() {
                var dock = $find("<%= RadDock1.ClientID %>");
                // Center the RadDock on the screen
                var viewPort = $telerik.getViewPortSize();
                var xPos = Math.round((viewPort.width - parseInt(dock.get_width())) / 2);
                var yPos = Math.round((viewPort.height - parseInt(dock.get_height())) / 2);
                $telerik.setLocation(dock.get_element(), { x: xPos, y: yPos });
                dock.set_closed(false);
                var descriptionTextBox = $get('<%= DescriptionText.ClientID %>');
                descriptionTextBox.focus();
                Sys.Application.remove_load(openForm);
            }
            function hideForm() {
                var dock = $find("<%= RadDock1.ClientID %>");
                dock.set_closed(true);
                return true;
            }
            function Export(sender, e) {
                $find("<%= DockPanel.ClientID %>").__doPostBack(sender.name, "");
            }
            function dockMoved(sender, args) {
                //Return RadDock to his original HTML parent so it gets updated via ajax
                $get("<%= DockPanel.ClientID %>").appendChild(sender.get_element());
            }
            function OnClientAppointmentClick(sender, args) {
                sender._contextMenuAppointment = args.get_appointment();
                args.get_appointment().showContextMenu(args.get_domEvent());
            }
            function OnClientTimeSlotClick(sender, args) {
                sender._showTimeSlotContextMenu(args.get_domEvent(), args.get_targetSlot());
            }
        </script>
    </telerik:RadScriptBlock>
    <asp:UpdatePanel runat="server" ID="UpdatePanel1">
        <ContentTemplate>
            <asp:Panel runat="server" ID="DockPanel">
                <telerik:RadDock runat="server" ID="RadDock1" Width="650px" Height="450px" Closed="true"
                    Style="z-index: 2000;" Title="Dettaglio appuntamento" OnClientDockPositionChanged="dockMoved"
                    BackColor="#FFEED5" BorderColor="#FFE6BF" BorderStyle="Solid" BorderWidth="1px">
                    <Commands>
                        <telerik:DockCloseCommand />
                    </Commands>
                    <ContentTemplate>
                        <div class="editForm">
                            <div class="header">
                                <asp:Label runat="server" ID="StatusLabel"></asp:Label>
                            </div>
                            <div class="content">
                                         
...
edit form fields
....

                            </div>
                        </div>
                    </ContentTemplate>
                </telerik:RadDock>
            </asp:Panel>
            <telerik:RadScheduler ID="RadScheduler1" runat="server" Skin="Windows7" SelectedView="TimelineView"
                Culture="it-IT" DayStartTime="08:00:00" StartEditingInAdvancedForm="false" OnFormCreating="RadScheduler1_FormCreating"
                Reminders-Enabled="false" FirstDayOfWeek="Monday" Height="1100px" DataSourceID="SqlDataSource1"
                WorkDayStartTime="08:30:00" CssClass="rsCategoryRed" RowHeaderWidth="70px" DataEndField="Fine"
                DataKeyField="ID" DataStartField="Start" DataSubjectField="Subject" DataDescriptionField="Description"
                OnTimeSlotCreated="RadScheduler1_TimeSlotCreated" DataReminderField="RecurrenceRule"
                EnableDescriptionField="True" OnAppointmentClick="RadScheduler1_OnAppointmentClick"
                OnClientAppointmentClick="OnClientAppointmentClick" OnClientTimeSlotClick="OnClientTimeSlotClick"
                WorkDayEndTime="19:00:00" RowHeight="50px" EnableExactTimeRendering="True" DayView-WorkDayEndTime="19:00"
                DayView-WorkDayStartTime="08:00" EnableCustomAttributeEditing="true" CustomAttributeNames="Terapista"
                OnAppointmentDataBound="RadScheduler1_AppointmentDataBound" OnAppointmentContextMenuItemClicked="RadScheduler1_OnAppointmentContextMenuItemClicked"
                DayEndTime="20:00:00" OnResourceHeaderCreated="RadScheduler1_ResourceHeaderCreated" ShowAllDayRow="False"
            BorderColor="#FFE6BF">
                <AdvancedForm Modal="true" />
                <ExportSettings OpenInNewWindow="true" FileName="SchedulerExport">
                    <Pdf PageTitle="Schedule" Author="" Creator="" Title="Schedule" />
                </ExportSettings>
                <TimelineView GroupBy="Room" NumberOfSlots="12" ColumnHeaderDateFormat="t" GroupingDirection="Vertical"
                    StartTime="08:00:00" ShowInsertArea="false" TimeLabelSpan="1" SlotDuration="00:30:00" />
                <ResourceTypes>
                    <telerik:ResourceType KeyField="ID" Name="Room" TextField="RoomName" ForeignKeyField="RoomID"
                        DataSourceID="RoomsDataSource" />
                </ResourceTypes>
                <ResourceHeaderTemplate>
                    <asp:Label ID="ResourceLabel" runat="server" Text=""></asp:Label>
                    </div>
                </ResourceHeaderTemplate>
                <TimeSlotContextMenuSettings EnableDefault="true" />
                <DayView DayEndTime="20:00:00" WorkDayEndTime="20:00:00" UserSelectable="false" />
                <WeekView UserSelectable="false" />
                <MonthView UserSelectable="false" />
                <MultiDayView DayEndTime="20:00:00" WorkDayEndTime="20.00:00:00" />
                <AppointmentContextMenuSettings EnableDefault="true" />
                <AppointmentContextMenus>
                    <telerik:RadSchedulerContextMenu ID="RadSchedulerContextMenu1" runat="server">
                        <Items>
                            <telerik:RadMenuItem runat="server" Text="Apri dettaglio" CssClass="menudestro">
                            </telerik:RadMenuItem>
                        </Items>
                    </telerik:RadSchedulerContextMenu>
                </AppointmentContextMenus>
                <AppointmentTemplate>
                    <div class='<%# impostaCss(Convert.ToString(Eval("ID"))) %>'>
                        <asp:Literal ID="AppointmentSubject" runat="server" Text='<%# Eval("Subject") %>'></asp:Literal>
                    </div>
                    <div style="float: right; margin-right: 15px">
                        <asp:Image ID="Image4" runat="server" ImageUrl='werp_cliente/categorie/nuovo.png'
                            Visible='<%# impostaIconNuovo(Convert.ToString(Eval("ID"))) %>' />
                    </div>
                    <div style="float: right; margin-right: 8px">
                        <asp:Image ID="Image1" runat="server" ImageUrl='werp_cliente/categorie/uomo.jpg'
                            Visible='<%# impostaIconCat1(Convert.ToString(Eval("ID"))) %>' />
                        <asp:Image ID="Image2" runat="server" ImageUrl='werp_cliente/categorie/rugby.jpg'
                            Visible='<%# impostaIconCat2(Convert.ToString(Eval("ID"))) %>' />
                        <asp:Image ID="Image3" runat="server" ImageUrl='werp_cliente/categorie/calcio.gif'
                            Visible='<%# impostaIconCat3(Convert.ToString(Eval("ID"))) %>' />
                    </div>
                </AppointmentTemplate>
            </telerik:RadScheduler>
            <asp:SqlDataSource ID="RoomsDataSource" runat="server" ConnectionString="<%$ ConnectionStrings:default %>"
                SelectCommand="SELECT [ID], [RoomName] FROM [Rooms]"></asp:SqlDataSource>
            <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:default %>"
                DeleteCommand="DELETE FROM [Appuntamenti] WHERE [ID] = @ID" InsertCommand="INSERT INTO [Appuntamenti] ([Subject], [Start], [Fine], [RecurrenceRule], [RecurrenceParentID], [Description], [RoomID], [Terapista]) VALUES (@Subject, @Start, @Fine, @RecurrenceRule, @RecurrenceParentID, @Description, @RoomID, @Terapista)"
                SelectCommand="SELECT * FROM [Appuntamenti] where [EliminatoErrore] =0 and [EliminatoDalCliente]=0"
                UpdateCommand="UPDATE [Appuntamenti] SET [Subject] = @Subject, [Start] = @Start, [Fine] = @Fine,[RecurrenceRule] = @RecurrenceRule, [RecurrenceParentID] = @RecurrenceParentID, [Description] = @Description, [RoomID] = @RoomID, [Terapista]=@Terapista WHERE [ID] = @ID">
                <DeleteParameters>
                    <asp:Parameter Name="ID" Type="Int32" />
                </DeleteParameters>
                <InsertParameters>
                    <asp:Parameter Name="Subject" Type="String" />
                    <asp:Parameter Name="Start" Type="DateTime" />
                    <asp:Parameter Name="Fine" Type="DateTime" />
                    <asp:Parameter Name="RecurrenceRule" Type="String" />
                    <asp:Parameter Name="RecurrenceParentID" Type="Int32" />
                    <asp:Parameter Name="Description" Type="String" />
                    <asp:Parameter Name="RoomID" Type="Int32" />
                    <asp:Parameter Name="ID" Type="Int32" />
                    <asp:Parameter Name="Terapista" Type="String" />
                </InsertParameters>
                <UpdateParameters>
                    <asp:Parameter Name="Subject" Type="String" />
                    <asp:Parameter Name="Start" Type="DateTime" />
                    <asp:Parameter Name="Fine" Type="DateTime" />
                    <asp:Parameter Name="RecurrenceRule" Type="String" />
                    <asp:Parameter Name="RecurrenceParentID" Type="Int32" />
                    <asp:Parameter Name="Description" Type="String" />
                    <asp:Parameter Name="RoomID" Type="Int32" />
                    <asp:Parameter Name="Terapista" Type="String" />
                </UpdateParameters>
            </asp:SqlDataSource>
        </ContentTemplate>
0
Peter
Telerik team
answered on 27 Jul 2012, 03:12 PM
Hello,

Please, take a look at the External Edit in RadDock demo. Notice that FormCreating has to be canceled or otherwise the default edit/insert form will show up.
protected void RadScheduler1_FormCreating(object sender, SchedulerFormCreatingEventArgs e)
       {
           RadSchedulerRecurrenceEditor1.ResetLayout();
 
           if (e.Mode == SchedulerFormMode.Insert || e.Mode == SchedulerFormMode.Edit)
           {
               EditedAppointment = e.Appointment;
               e.Cancel = true;
           }
 
           var appointmentToEdit = RadScheduler1.PrepareToEdit(e.Appointment, RadScheduler1.EditingRecurringSeries);
 
           ScriptManager.RegisterStartupScript(Page, GetType(), "formScript", "Sys.Application.add_load(openForm);", true);
           PopulateEditForm(appointmentToEdit);
       }



Regards,
Peter
the Telerik team
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.
0
TT
Top achievements
Rank 1
answered on 27 Jul 2012, 04:10 PM
it's already like that and two edit forms appear.
i have to set any radscheduler's property?
0
Accepted
Peter
Telerik team
answered on 30 Jul 2012, 10:55 AM
Hi,

The online demo relies on that StartEditingInAdvancedForm="false" is set for RadScheduler, so that the simple inline form shows up. If that's not the case with your settings, then you need to change the contion:
protected void RadScheduler1_FormCreating(object sender, SchedulerFormCreatingEventArgs e)
   {
       if (e.Mode == SchedulerFormMode.AdvancedEdit || e.Mode == SchedulerFormMode.AdvancedInsert)
       {
        
       }
   }

Notice the difference with the original demo code:
***
if (e.Mode == SchedulerFormMode.Insert || e.Mode == SchedulerFormMode.Edit)
***

Is this helpful?

Greetings,
Peter
the Telerik team
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.
0
TT
Top achievements
Rank 1
answered on 30 Jul 2012, 12:42 PM
yes thank you, it's works!
Tags
Scheduler
Asked by
TT
Top achievements
Rank 1
Answers by
Peter
Telerik team
TT
Top achievements
Rank 1
Share this question
or