Rad Scheduler: Drag and Drop: modified appointment has unchanged value

3 posts, 0 answers
  1. rjb227s
    rjb227s avatar
    17 posts
    Member since:
    Apr 2009

    Posted 19 Jan 2010 Link to this post

    Hello,

    I am having this same issue and the solution below was unfortunately not a helpful answer.  I have spent so many hours on this I have lost count. 

    When dragging and dropping an appointment, the AppointmentUpdate Server event has the same value for the event args for the e.Appointment AND e.ModifiedAppointment.  When I add the client event OnClientAppointmentMoveEnd, I get the correct modified value on the client side, but the serverside is always wrong.

    [.net 2.0 + Q3 2009 with hotfix]

    Thanks for the help,

    Ryan (Code Below)

    Server Code: (values for e.Appointment and e.ModifiedAppointment are the same)
    protected void CalendarRadScheduler_AppointmentUpdate(object sender, AppointmentUpdateEventArgs e) 
            { 
                if (e.Appointment.Start != e.ModifiedAppointment.Start) 
                { 
                    Appointment objModApt = e.ModifiedAppointment; 
     
                    //load message from database 
                    MessageDAO daoMessage = new MessageDAO(); 
                    MessageDTO dtoMessage = daoMessage.GetById((int)objModApt.ID); 
     
                    //update message with new time 
                    dtoMessage.Start = objModApt.Start; 
                    dtoMessage.End = objModApt.Start.AddMinutes(10); 
     
                    //Save updated message to database 
                    dtoMessage.Method = CoreToolkit.ObjectMethod.Modify; 
                    daoMessage.Save(dtoMessage); 
                } 
                else 
                { 
                    e.Cancel = true
                } 
            } 

    Client Code:
    <%@ Control Language="C#" AutoEventWireup="true" Codebehind="MyUserControl.ascx.cs"  
        Inherits="UserControls.MyUserControl" %>  
    <meta http-equiv="X-UA-Compatible" content="IE=7"/>  
      
    <pro:RadCodeBlock ID="RadCodeBlock1" runat="server">  
      
    <script type="text/javascript"


     function OnClientAppointmentMoveEnd(sender, eventArgs)
               {
                alert("New start time: " + eventArgs.get_newStartTime());
               }
                            
      
                function formatDate(date)  
                {  
                    var year = padNumber(date.getFullYear(), 4);  
                    var month = padNumber(date.getMonth() + 1, 2);  
                    var day = padNumber(date.getDate(), 2);  
                    var hour = padNumber(date.getHours(), 2);  
                    var minute = padNumber(date.getMinutes(), 2);  
                      
                    return year + month + day + hour + minute;  
                }  
                  
                function padNumber(number, totalDigits)  
                {  
                    numbernumbernumber = number.toString();  
                    var padding = '';  
                    if (totalDigits > number.length)  
                    {  
                        for (i = 0; i < (totalDigits - number.length); i++)  
                        {  
                            padding += '0';  
                        }  
                    }  
                      
                    return padding + number.toString();  
                }  
                      
                //prevent resizing  
              function OnClientAppointmentResizeStart(sender, eventArgs)  
              {  
                 alert('no resizing');  
                 //eventArgs.set_cancel(true);  
              }  
                  
                //prevent resizing  
              function OnClientAppointmentResizeEnd(sender, eventArgs)  
              {           
                alert('resizing end')                           
              }  
                
              //prevent editing of recurring messages  
              function OnClientAppointmentEditing(sender, eventArgs)  
              {  
                alert('editing');  
                if(eventArgs.get_editingRecurringSeries())  
                      eventArgs.set_cancel(true);  
              }  
                
              function OnClientAppointmentDoubleClick(sender, eventArgs)  
              {  
                  alert('here');  
              }  
                
              function OnClientAppointmentInserting(sender, eventArgs)  
                {  
                     var start = formatDate(eventArgs.get_startTime());  
                       
                     document.location.href = '<%=PageToRedirect + "?StartDate="%>' + start;  
                     eventArgs.set_cancel(true);  
                }    
                  
        </script>  
      
    </pro:RadCodeBlock>  
    <telerik:RadScriptBlock runat="server" ID="scriptContextMenu">  
      
            <script type="text/javascript">  
                var selectedAppointment = null;  
                var contextMenuSlot = null;  
      
                function checkResourceMenuItem(menu, appointment) {  
                    var calendar = appointment.get_resources().getResourcesByType("Calendar").getResource(0);  
                    if (!calendar)  
                        return;  
      
                    var actionItem = menu.findItemByText("Action");  
                    //Traverse all menu items below "Action"  
                    for (var i = 0; i < actionItem.get_items().get_count(); i++) {  
                        var item = actionItem.get_items().getItem(i);  
                        if (item.get_value() == calendar.get_key()) {  
                            //The item corresponds to the current "Calendar" - the Value of the item stores the Key of the resource  
                            item.set_imageUrl("Images/checked.gif");  
                        }  
                        else {  
                            item.set_imageUrl("");  
                        }  
                    }  
                }  
      
                //Called when the user right-clicks an appointment  
                function appointmentContextMenu(sender, eventArgs) {  
                    var menu = $find("<%= SchedulerAppointmentContextMenu.ClientID %>");  
                    selectedAppointment = eventArgs.get_appointment();  
                    checkResourceMenuItem(menu, selectedAppointment);  
                    menu.show(eventArgs.get_domEvent());  
                }  
      
                //Called when the user clicks an item from the appointment context menu  
                function appointmentContextMenuItemClicking(sender, eventArgs) {  
                    var clickedItem = eventArgs.get_item();                  
                    if (clickedItem.get_text() == "Action") {  
                        //Prevent the menu from closing if the user clicked the "Action" menu item  
                        eventArgs.set_cancel(true);  
                        return;  
                    }  
                }  
      
                //Called when the user clicks an item from the appointment context menu  
                function appointmentContextMenuItemClicked(sender, eventArgs)   
                {  
                      
                    if (!selectedAppointment)  
                        return;  
      
                    var clickedItem = eventArgs.get_item();  
                    var scheduler = $find("<%= CalendarRadScheduler.ClientID %>");  
      
                    if (clickedItem.get_parent().get_text && clickedItem.get_parent().get_text() == "Action") {  
                        //The user clicked the item corresponding to the "Calendar" resource to which the appointment is assigned  
                        if (clickedItem.get_imageUrl())  
                            return;  
      
                        //Clear all resources   
                        selectedAppointment.get_resources().clear();  
                        //Find the resource corresponding to the clicked item  
                        var calendar = scheduler.get_resources().getResourceByTypeAndKey("Calendar", clickedItem.get_value());  
                        //Add it to the appointment resources collection  
                        selectedAppointment.get_resources().add(calendar);  
                        //Update the appointment  
                        scheduler.updateAppointment(selectedAppointment);  
                    }  
                }             
                  
                function OnClientRecurrenceActionDialogShowing(sender, eventArgs)  
               {  
                   alert('in OnClientRecurrenceActionDialogShowing()');  
                   eventArgs.set_cancel(true);    
                    
                   //Edit this instance only:    
                   eventArgs.set_editSeries(false);    
               }          
                 
               function CalendarRadScheduler_AppointmentContextMenuItemClicked(sender, eventArgs)  
               {  
                alert('you click a menu button');  
               }  
                 
               function OnClientNavigationCommand(sender, eventArgs)  
               {  
                  alert('Navigation Command:');  
                  alert(eventArgs.get_selectedDate().toString());                
               }  
                 
            </script>  
      
        </telerik:RadScriptBlock>  
      
      
    <pro:RadAjaxManager ID="RadAjaxManager1" EnableAJAX="true" runat="server" OnAjaxRequest="RadAjaxManager1_AjaxRequest">  
        <AjaxSettings>  
            <pro:AjaxSetting AjaxControlID="CalendarRadScheduler">  
                <UpdatedControls>  
                    <telerik:AjaxUpdatedControl ControlID="CalendarRadScheduler" LoadingPanelID="RadAjaxLoadingPanel1" />  
                </UpdatedControls>  
            </pro:AjaxSetting>  
        </AjaxSettings>  
    </pro:RadAjaxManager>  
      
            <pro:RadScheduler   
                ID="CalendarRadScheduler"   
                runat="server"   
                EnableAjaxSkinRendering="false"  
                Height="750px"   
                Width="578px"   
                ShowAllDayRow="False"   
                AllowDelete="True"   
                AllowEdit="True"  
                AllowInsert="True"   
                Skin="Office2007"  
                HoursPanelTimeFormat="h:mm tt"   
                MinutesPerRow="15"   
                ShowFullTime="True"  
                StartEditingInAdvancedForm="false"  
                DataKeyField="ID"   
                DataSubjectField="Subject"   
                DataStartField="Start"   
                DataEndField="End"  
                DataRecurrenceField="RecurrenceRule"   
                DataRecurrenceParentKeyField="RecurrenceParentID"  
                DayEndTime="18:30:00"   
                DayStartTime="08:00:00"   
                ShowFooter="false"   
                OnClientAppointmentInserting="OnClientAppointmentInserting"  
                OnClientAppointmentDoubleClick="OnClientAppointmentDoubleClick"  
                OnClientAppointmentEditing="OnClientAppointmentEditing"   
                OnClientAppointmentResizeEnd="OnClientAppointmentResizeEnd"  
                OnAppointmentCreated="CalendarRadScheduler_AppointmentCreated"   
                OnAppointmentDataBound="CalendarRadScheduler_AppointmentDataBound"   
                CustomAttributeNames="NetworkId"   
                OnAppointmentCommand="CalendarRadScheduler_AppointmentCommand"   
                OnFormCreating="CalendarRadScheduler_FormCreating"   
                OnAppointmentContextMenuItemClicked="CalendarRadScheduler_AppointmentContextMenuItemClicked"   
                OnAppointmentUpdate="CalendarRadScheduler_AppointmentUpdate"  
                OnClientRecurrenceActionDialogShowing ="OnClientRecurrenceActionDialogShowing"   
                OnClientNavigationCommand="OnClientNavigationCommand" 
                OnClientAppointmentMoveEnd="OnClientAppointmentMoveEnd"
                OnNavigationCommand="CalendarRadScheduler_NavigationCommand">  
                  
                <AppointmentContextMenus>  
                    <%--The appointment context menu interaction is handled on the client in this example--%>  
                    <%--See the JavaScript code above--%>  
                    <telerik:RadSchedulerContextMenu runat="server" ID="SchedulerAppointmentContextMenu">  
                        <Items>  
                            <telerik:RadMenuItem Text="View" Value="CommandView" />  
                            <telerik:RadMenuItem IsSeparator="True" />  
                            <telerik:RadMenuItem Text="Copy" Value="CommandCopy" ImageUrl="/images/copy.gif"/>  
                            <telerik:RadMenuItem IsSeparator="True" />  
                            <telerik:RadMenuItem Text="Edit" Value="CommandEdit" ImageUrl="/images/edit.gif"/>  
                            <telerik:RadMenuItem IsSeparator="True" />  
                            <telerik:RadMenuItem Text="Delete" Value="CommandDelete" ImageUrl="/images/icon_trash.gif" />  
                            <telerik:RadMenuItem IsSeparator="True" />  
                            <telerik:RadMenuItem Text="Action" Visible="false">  
                                <Items>  
                                    <telerik:RadMenuItem Text="Development" Value="1" />  
                                    <telerik:RadMenuItem Text="Marketing" Value="2" />  
                                    <telerik:RadMenuItem Text="Personal" Value="3" />  
                                    <telerik:RadMenuItem Text="Work" Value="4" />  
                                </Items>  
                            </telerik:RadMenuItem>  
                             
                        </Items>  
                    </telerik:RadSchedulerContextMenu>  
                </AppointmentContextMenus>  
                <AppointmentTemplate>  
                    <div>  
                        <%# FormatCalendarMessage() %>  
                    </div>  
                </AppointmentTemplate>  
                  
            </pro:RadScheduler>  
          
    <asp:Label ID="lbl" runat="server" Visible="false"></asp:Label>  
    <pro:RadAjaxLoadingPanel   
        ID="RadAjaxLoadingPanel1"   
        runat="server"   
        Transparency="30"  
        BackColor="#E0E0E0"   
        InitialDelayTime="500">  
            <asp:Image ID="Image2" Style="margin-top: 200px" runat="server" ImageUrl="/images/loading.gif" BorderWidth="0px" AlternateText="Loading"></asp:Image>  
    </pro:RadAjaxLoadingPanel>  

  2. Peter
    Admin
    Peter avatar
    6637 posts

    Posted 20 Jan 2010 Link to this post

    Hello Ryan,

    The best way to help you out quickly is to open a support ticket and send us a simple working demo of the problem. Once we receive it we will do our best to resolve the problem asap.


    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.
  3. Amit
    Amit avatar
    1 posts
    Member since:
    May 2011

    Posted 03 Nov 2011 Link to this post

    same problem here , please suggest the answer.
Back to Top