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

Rad Scheduler: Navigation Date Picker not working (help)

1 Answer 344 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
rjb227s
Top achievements
Rank 1
rjb227s asked on 18 Jan 2010, 07:07 AM
Hello,

I am trying to chase down an issue as to why the date picker doesn't seem to be working in my rad scheduler.

Current State:  Clicking any date in the date picker in the navigation panel posts back and displays "today" regardless of what is selected.

In an attempt to chase down the issue, I am stepping through the client and server side events for this click.

Client Side:
function OnClientNavigationCommand(sender, eventArgs) 
           { 
              alert('Navigation Command:'); 
              alert(eventArgs.get_selectedDate().toString());               
           } 

If today = 1/1/10 and I select 2/25/10 --> This alert shows the date of "1/1/10" rather than "2/25/10".  The alert then shows a 2nd time and shows the date of "2/25/10" as expected.  This seems like the correct behavior might still happen on the server since the most recent execution of this client method showed the right value before posting back....but it doesn't ... see below.



Server Side:
 protected void CalendarRadScheduler_NavigationCommand(object sender, SchedulerNavigationCommandEventArgs e) 
        { 
            //if user used the datepicker 
            if (e.Command == SchedulerNavigationCommand.NavigateToSelectedDate) 
            { 
                CalendarRadScheduler.SelectedView = SchedulerViewType.DayView; 
                CalendarRadScheduler.SelectedDate = e.SelectedDate; 
            } 
        } 
 
I set a breakpoint in this event to see the selected date value being sent to the server using the same values stated above.  The expected value "e.SelectedDate" is "2/25/10", but it instead always shows today's value ....or in this example "1/1/10". 

The Rad Scheduler control is in a user control that is in a page by itself.

Here is the code for my ascx page (.net 2.0) [below is the server side code that binds data to the calendar]
<%@ 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 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) 
            { 
                numbernumber = 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" 
            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> 
 
 
 

Server Side Code that binds data to calendar:
 private void GetMessagesForCalendar() 
        { 
            string strUserIdList = BuildUserList(); 
            MessageDAO daoMessage = new MessageDAO(); 
            DataTable dt = daoMessage.GetMessagesForCalendar(strUserIdList); 
 
            //Build list of appointments 
            List<Appointment> lstAppointments = new List<Appointment>(); 
 
            foreach (DataRow dr in dt.Rows) 
            { 
                Appointment objApt = new Appointment(); 
                objApt.Owner = CalendarRadScheduler; 
                objApt.ID = Convert.ToInt32(dr["MessageId"]); 
                objApt.Subject = Convert.ToString(dr["MessageText"]); 
                //add custom attribute to hold the social network 
                objApt.Attributes["NetworkId"] = Convert.ToString(dr["NetworkId"]); 
                //objApt.Start = DateTime.SpecifyKind(Convert.ToDateTime(dr["Start"]), DateTimeKind.Utc); 
                objApt.Start = Convert.ToDateTime(dr["Start"]); 
                objApt.End = Convert.ToDateTime(dr["End"]); 
                objApt.RecurrenceRule = Convert.ToString(dr["RecurrenceRule"]); 
                objApt.RecurrenceParentID = dr["RecurrenceParentId"]; 
                objApt.RecurrenceState = RecurrenceState.Master; 
 
                lstAppointments.Add(objApt); 
            } 
 

            CalendarRadScheduler.DataSource = lstAppointments; 
            CalendarRadScheduler.Rebind(); 
        } 


Thanks,

Ryan


1 Answer, 1 is accepted

Sort by
0
rjb227s
Top achievements
Rank 1
answered on 18 Jan 2010, 03:46 PM
I solved this one:

Issue:  I was binding the scheduler and setting the SelectedDate in the Page_Load() method.  This should instead be in the On_Init() method.  By moving the server-side binding to this location, I am no longer resetting the SelectedDate at the incorrect step in the order of operations.
Tags
Scheduler
Asked by
rjb227s
Top achievements
Rank 1
Answers by
rjb227s
Top achievements
Rank 1
Share this question
or