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

Javacript error while hiding some Recurrences of RadSchedulerRecurrenceEditor

10 Answers 268 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
Tiffany Phan
Top achievements
Rank 1
Tiffany Phan asked on 23 May 2011, 04:02 PM
Hi Veronica,

My co-worker and I are trying to create a test user profile to test our application and we saw a javacript error like:
    Sys.InvalidOperationException: Handler must be a function

This error prevented us to retrieve our appointments on RadScheduler. 
I researched the Internet and somebody suggested to remove brackets/parenthenses when we call the event on the client side.  For example, before I had this on my RadScheduler:  
    OnClientFormCreated="OnClientFormCreated()"     I changed this into:  OnClientFormCreated="OnClientFormCreated"   

It works.  However, all my javacript codes inside this function are not working.  For example, I tried to hide options of reccurences like Hourly, Monthly, Yearly, End after, Saturday and Sunday checkboxes of weekly recurrence (see my following codes).  My question is which argument I should use to make these work like before:

function OnClientFormCreated(sender, eventArgs) 
                {
                    $telerik.$(".rsRecurrenceOptionList li:first-child").hide();
                    $telerik.$(".rsRecurrenceOptionList li:eq(1)").hide();                                                                    
                    $telerik.$(".rsRecurrenceOptionList li:eq(4)").hide();   
                    $telerik.$('input[id=RadScheduler1_Form_WeeklyWeekDaySaturday]').attr('checked', false); 
                    $telerik.$('input[id=RadScheduler1_Form_WeeklyWeekDaySunday]').attr('checked', false);                                
                    $telerik.$(".rsAdvWeekly_WeekDays li:eq(0)").hide();
                    $telerik.$(".rsAdvWeekly_WeekDays li:nth-child(5)").css("clear","");                     
                    $telerik.$(".rsAdvWeekly_WeekDays li:eq(6)").hide();                                                  
                    $telerik.$(".rsAdvRecurrenceRangePanel .rsAdvOptionsPanel ul li:nth-child(2)").hide();                                   
                }
Please help! 

Thanks so much!

Tiffany Phan


10 Answers, 1 is accepted

Sort by
0
Veronica
Telerik team
answered on 26 May 2011, 03:17 PM
Hello Tiffany,

Yes, you should not add brackets/parentheses to the handlers of the javascript events. I just tried the OnClientFormCreated event again and it works perfect on my side. Here's the code as follows:

ASPX:
<telerik:RadScheduler runat="server" ID="RadScheduler1" OnClientFormCreated="OnClientFormCreated">
    </telerik:RadScheduler>

JavaScript:
function OnClientFormCreated(sender, eventArgs) {
           $telerik.$(".rsRecurrenceOptionList li:first-child").hide();
           $telerik.$(".rsRecurrenceOptionList li:eq(1)").hide();
           $telerik.$(".rsRecurrenceOptionList li:eq(4)").hide();
           $telerik.$('input[id=RadScheduler1_Form_WeeklyWeekDaySaturday]').attr('checked', false);
           $telerik.$('input[id=RadScheduler1_Form_WeeklyWeekDaySunday]').attr('checked', false);
           $telerik.$(".rsAdvWeekly_WeekDays li:eq(0)").hide();
           $telerik.$(".rsAdvWeekly_WeekDays li:nth-child(5)").css("clear", "");
           $telerik.$(".rsAdvWeekly_WeekDays li:eq(6)").hide();
           $telerik.$(".rsAdvRecurrenceRangePanel .rsAdvOptionsPanel ul li:nth-child(2)").hide();
       }

Please make sure that the name of the event handler is the same in both the markup and the script (I've highlighted mine in yellow). Also please note that they are case-sensitive.

If you still need help - could you please send me your code so I can inspect it and help you?

Thank you!

All the best,
Veronica Milcheva
the Telerik team

Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

0
Tiffany Phan
Top achievements
Rank 1
answered on 27 May 2011, 08:36 PM
Hi Veronica,

First, thank you for your response.  That's good to know they are case-sensitive.
I forgot to tell you that I used "External Edit in RadDock" which I had Update Panel, RadDock, and RadSchedulerRecurrenceEditor by itself.  I think RadSchedulerRecurrenceEditor did not work correctly eventhough I followed your direction.  I am about to paste my aspx page and aspx.vb page here, so you can inspect it for me.  When you run it, just simply double click on any slot of radscheduler and when the form opens, just check recurrence checkbox, and you will see.  Here is the code of my aspx page:

<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %>
  
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<head runat="server">
    <title></title>
    <telerik:RadStyleSheetManager ID="RadStyleSheetManager1" runat="server" />
    <style type="text/css">
        </style>
</head>
<body>
    <form id="form1" runat="server">
    <asp:ScriptManager ID="ScriptManager1" runat="server">
    </asp:ScriptManager>
  
    <script type="text/javascript">
        //Put your JavaScript code here.
         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);                 
                    dock.enableModalExtender();
                    Sys.Application.remove_load(openForm);
                }
                  
                function hideForm()
                {
                    var dock = $find("<%= RadDock1.ClientID %>");
                    dock.disableModalExtender();
                    dock.set_closed(true);
                      
                    return true;                    
                      
                }
                  
                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 dockClose(dock, args) {
                    dock.disableModalExtender();
                }
                  
                function dockInitialize(dock, args) {
                //telerik: If postback occured. Move a RadDock to the center and show the modal extender.
                    if (dock.get_closed() == false) {
                        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.enableModalExtender();
                    }
                }
                       
                function OnClientFormCreated(sender, eventArgs) 
                {
                    $telerik.$('input[id=RadScheduler1_Form_WeeklyWeekDaySaturday]').attr('checked', false); 
                    $telerik.$('input[id=RadScheduler1_Form_WeeklyWeekDaySunday]').attr('checked', false);      
                    $telerik.$(".rsRecurrenceOptionList li:first-child").hide();
                    $telerik.$(".rsRecurrenceOptionList li:eq(1)").hide();                                                                    
                    $telerik.$(".rsRecurrenceOptionList li:eq(4)").hide();                                                 
                    $telerik.$(".rsAdvWeekly_WeekDays li:eq(0)").hide();
                    $telerik.$(".rsAdvWeekly_WeekDays li:nth-child(5)").css("clear","");                     
                    $telerik.$(".rsAdvWeekly_WeekDays li:eq(6)").hide();                                                  
                    $telerik.$(".rsAdvRecurrenceRangePanel .rsAdvOptionsPanel ul li:nth-child(2)").hide();                                   
                }  
                  
                function OnClientRecurrenceActionDialogShowing(sender, eventArgs)
                {
                     eventArgs.set_cancel(true);
                    //Edit this instance only:
                    //eventArgs.set_editSeries(false);
                      
                    //Edit the entire series:
                    eventArgs.set_editSeries(true);
                }
                  
                function OnClientAppointmentMoveStart(sender, e)
                {
                     $find("RadAjaxManager1").ajaxRequest(e.get_appointment().get_id());
                }
                  
    </script>
  
    <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
    </telerik:RadAjaxManager>
    <asp:UpdatePanel ID="UpdatePanel1" runat="server">
        <ContentTemplate>
            <telerik:RadScheduler ID="RadScheduler1" runat="server" Width="700px" Height="630px" StartEditingInAdvancedForm="False"
                OnClientFormCreated="OnClientFormCreated" DataEndField="EndDate" DataKeyField="ID"
                DataRecurrenceField="RecurrenceRule" DataRecurrenceParentKeyField="RecurrenceParentID"
                DataSourceID="ldsActivitySchedules" DataStartField="StartDate" DataSubjectField="Subject"
                AllowDelete="False" ShowAllDayRow="False" OnClientRecurrenceActionDialogShowing="OnClientRecurrenceActionDialogShowing"
                OnFormCreating="RadScheduler1_FormCreating" OnClientAppointmentMoveStart="OnClientAppointmentMoveStart"
                CustomAttributeNames="ActivityID,MaxClassSize" FirstDayOfWeek="Monday" LastDayOfWeek="Friday"
                MinutesPerRow="15" SelectedView="WeekView" Skin="Office2007">
                <TimelineView UserSelectable="False" />
                <AdvancedForm Modal="True" />
            </telerik:RadScheduler>
            <asp:Panel runat="server" ID="DockPanel" Width="642px">
                <telerik:RadDock runat="server" ID="RadDock1" Width="638px" Height="500px" Closed="True"
                    Style="z-index: 2000;" Title="Edit appointment" DefaultCommands="None" OnClientDockPositionChanged="dockMoved"
                    CloseText="" OnClientInitialize="dockInitialize">
                    <Commands>
                        <telerik:DockCloseCommand OnClientCommand="dockClose" />
                    </Commands>
                    <ContentTemplate>
                        <div>
                            <div>
                                <asp:Label runat="server" ID="StatusLabel"></asp:Label>
                            </div>
                            <div>
                                <table>
                                    <tr align="left">
                                        <td style="color: Navy; font-family: 'Segoe UI', Arial, Verdana, bold; font-size: 11px;">
                                            Activity Name:
                                        </td>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td style="color: Navy; font-family: 'Segoe UI', Arial, Verdana, bold; font-size: 11px;">
                                            <telerik:RadTextBox ID="txtSubject" runat="server" Width="200px">
                                            </telerik:RadTextBox>
                                        </td>
                                        <td style="color: Navy; font-family: 'Segoe UI', Arial, Verdana, bold; font-size: 11px;
                                            height: 20px;">
                                        </td>
                                        <td style="color: Navy; font-family: 'Segoe UI', Arial, Verdana, bold; font-size: 11px;
                                            height: 20px;">
                                        </td>
                                    </tr>
                                    <tr>
                                        <td style="color: Navy; font-family: 'Segoe UI', Arial, Verdana, bold; font-size: 11px;
                                            height: 20px;">
                                            Class Start Date:
                                            <br />
                                            <telerik:RadDatePicker ID="StartDate" runat="server" Culture="English (United States)"
                                                SharedCalendarID="SharedCalendar" Width="100px">
                                            </telerik:RadDatePicker>
                                            <asp:RequiredFieldValidator ID="rfvStartDate" runat="server" ControlToValidate="StartDate"
                                                Display="Dynamic" ErrorMessage="Required field!" Style="font-family: 'Segoe UI', Arial, Verdana;
                                                font-size: 11px" />
                                        </td>
                                        <td style="color: Navy; font-family: 'Segoe UI', Arial, Verdana, bold; font-size: 11px;">
                                        </td>
                                        <td style="color: Navy; font-family: 'Segoe UI', Arial, Verdana, bold; font-size: 11px;
                                            height: 20px;">
                                              
                                        </td>
                                    </tr>
                                    <tr>
                                        <td style="color: Navy; font-family: 'Segoe UI', Arial, Verdana, bold; font-size: 11px;">
                                            Start Time:<br />
                                        </td>
                                        <td style="color: Navy; font-family: 'Segoe UI', Arial, Verdana, bold; font-size: 11px;
                                            height: 20px;">
                                            End Time:<br />
                                        </td>
                                    </tr>
                                    <tr>
                                        <td class="style2">
                                            <telerik:RadTimePicker ID="StartTime" runat="server" SharedTimeViewID="SharedTimeView"
                                                Culture="English (United States)" Width="100px">
                                            </telerik:RadTimePicker>
                                            <br />
                                            <asp:RequiredFieldValidator ID="rfvStartTime" runat="server" ControlToValidate="StartTime"
                                                Display="Dynamic" ErrorMessage="Required field!" Style="font-family: 'Segoe UI', Arial, Verdana;
                                                font-size: 11px" />
                                            <br />
                                        </td>
                                        <td style="height: 41px">
                                            <telerik:RadTimePicker ID="EndTime" runat="server" SharedTimeViewID="SharedTimeView"
                                                Culture="English (United States)" Width="100px">
                                            </telerik:RadTimePicker>
                                            <br />
                                            <asp:RequiredFieldValidator ID="rfvEndTime" runat="server" ControlToValidate="EndTime"
                                                Display="Dynamic" ErrorMessage="Required field!" Style="font-family: 'Segoe UI', Arial, Verdana;
                                                font-size: 11px" />
                                            <br />
                                        </td>
                                    </tr>
                                    <tr>
                                        <td colspan="2">
                                            <telerik:RadSchedulerRecurrenceEditor ID="RecurrenceEditor1" runat="server" Width="600px"
                                                Style="color: Navy; font-family: 'Segoe UI', Arial, Verdana, bold; font-size: 11px"
                                                FirstDayOfWeek="Monday">
                                            </telerik:RadSchedulerRecurrenceEditor>
                                               
                                        </td>
                                    </tr>
                                </table>
                            </div>
                            <br />
                            <br />
                            <telerik:RadTimeView ID="SharedTimeView" runat="server" Height="200px" Interval="00:15:00"
                                EndTime="19:15:00" StartTime="07:00:00">
                            </telerik:RadTimeView>
                            <telerik:RadCalendar ID="SharedCalendar" runat="server" EnableMonthYearFastNavigation="False"
                                EnableMultiSelect="False" UseColumnHeadersAsSelectors="False" UseRowHeadersAsSelectors="False">
                            </telerik:RadCalendar>
                        </div>
                    </ContentTemplate>
                </telerik:RadDock>
            </asp:Panel>
        </ContentTemplate>
    </asp:UpdatePanel>
    <asp:LinqDataSource ID="ldsActivitySchedules" runat="server" ContextTypeName="MyDataClassesDataContext"
        EnableInsert="True" EnableUpdate="True" TableName="ACTIVITYSCHEDULEs" Where="Deleted == @Deleted">
        <WhereParameters>
            <asp:QueryStringParameter DefaultValue="False" Name="Deleted" QueryStringField="Deleted"
                Type="Boolean" />
        </WhereParameters>
    </asp:LinqDataSource>
    <telerik:RadWindowManager ID="RadWindowManager1" runat="server" Skin="Outlook">
    </telerik:RadWindowManager>
  
    <script type="text/javascript">
              
            Telerik.Web.UI.RadDock.prototype.enableModalExtender = function() {
                if (!this._modalExtender) {
                    this._modalExtender = new Telerik.Web.UI.ModalExtender(this.get_element());
                }
                this._modalExtender.show();
            };
            Telerik.Web.UI.RadDock.prototype.disableModalExtender = function() {
                if (this._modalExtender) {
                    this._modalExtender.hide();
                }
            };
  
            Telerik.Web.UI.RadDock.prototype.dispose = function() {
                if (this._modalExtender) {
                    this._modalExtender.dispose();
                    this._modalExtender = null;
                }
                Telerik.Web.UI.RadDock.callBaseMethod(this, 'dispose');
            };
    </script>
  
    </form>
</body>
</html>

And this is my aspx.vb page:

Imports System
Imports Telerik.Web.UI
Imports System.Web.UI
Imports System.Data.Linq
Imports System.Convert
  
Partial Class _Default
    Inherits System.Web.UI.Page
  
    Private _dataContext As MyDataClassesDataContext
  
#Region " Defines Data Context "
    ''' <summary>
    ''' Defines Data Context for Schedule Database 
    ''' </summary>
    ''' Tiffany created 5/27/2011
    ''' <value></value>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Protected ReadOnly Property DbContext() As MyDataClassesDataContext
        Get
            If _dataContext Is Nothing Then
                _dataContext = New MyDataClassesDataContext()
            End If
            Return _dataContext
        End Get
    End Property
  
    Public Overloads Overrides Sub Dispose()
        If _dataContext IsNot Nothing Then
            _dataContext.Dispose()
        End If
        MyBase.Dispose()
    End Sub
#End Region
  
#Region " Get appointment ID as an object "
    ''' <summary>
    ''' Get appointment ID
    ''' </summary>
    ''' Tiffany created 5/27/2011
    ''' <value></value>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Protected Property EditedAppointmentID() As Object
        Get
            Return ViewState("EditedAppointmentID")
        End Get
        Set(ByVal value As Object)
            ViewState("EditedAppointmentID") = value
        End Set
    End Property
#End Region
  
#Region "RadScheduler1_FormCreating"
    ''' <summary>
    ''' Opens radscheduler
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    ''' <remarks></remarks>
    Protected Sub RadScheduler1_FormCreating(ByVal sender As Object, ByVal e As Telerik.Web.UI.SchedulerFormCreatingEventArgs) Handles RadScheduler1.FormCreating
        If e.Mode = SchedulerFormMode.Insert OrElse e.Mode = SchedulerFormMode.Edit Then
            EditedAppointmentID = e.Appointment.ID
            e.Cancel = True
            RadScheduler1.Enabled = False
            ScriptManager.RegisterStartupScript(Page, [GetType](), "formScript", "Sys.Application.add_load(openForm);", True)
  
            PopulateEditForm(e.Appointment)
  
        End If
    End Sub
#End Region
  
#Region " PopulateEditForm "
    ''' <summary>
    ''' Displays details of an appointment
    ''' </summary>
    ''' Tiffany created 5/27/2011
    ''' <param name="editedAppointment"></param>
    ''' <remarks></remarks>
    Protected Sub PopulateEditForm(ByVal editedAppointment As Appointment)
  
        Dim appointmentToEdit As Appointment = RadScheduler1.PrepareToEdit(editedAppointment, True)
        Dim storedRule As String = Nothing
  
        If appointmentToEdit.ID Is Nothing Then
  
            StartDate.SelectedDate = editedAppointment.Start.ToShortDateString
            StartTime.SelectedDate = editedAppointment.Start
            EndTime.SelectedDate = editedAppointment.End
  
            '**** Did not refresh recurrence editor and this is a bug of telerik even though I cleared out the
            'recurrence editor; they said they are working on this
            RecurrenceEditor1.RecurrenceRule = Nothing
            RecurrenceEditor1.RecurrenceRuleText = storedRule
            RecurrenceEditor1.RecurrenceRuleText = (System.Convert.DBNull).ToString
            '*****End clearing the recurrence editor
        Else
  
            ViewState("ActivityID") = appointmentToEdit.Attributes("ActivityID")
  
            StartDate.SelectedDate = RadScheduler1.UtcToDisplay(appointmentToEdit.Start)
            StartTime.SelectedDate = RadScheduler1.UtcToDisplay(appointmentToEdit.Start)
            EndTime.SelectedDate = RadScheduler1.UtcToDisplay(appointmentToEdit.End)
  
            storedRule = appointmentToEdit.RecurrenceRule
            RecurrenceEditor1.RecurrenceRuleText = appointmentToEdit.RecurrenceRule
  
            Dim actDropDown As Resource = appointmentToEdit.Resources.GetResourceByType("Activity")
  
        End If
    End Sub
#End Region
  
#Region "Page_LoadComplete"
    ''' <summary>
    ''' Page load complete
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    ''' <remarks></remarks>
    Protected Sub Page_LoadComplete(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.LoadComplete
  
        If Not IsPostBack Then
            'do something
        Else
            RadScheduler1.Enabled = True
        End If
    End Sub
#End Region
  
End Class

Please help!

Thanks a lot.

Tiffany Phan
0
Veronica
Telerik team
answered on 31 May 2011, 09:31 AM
Hi Tiffany,

Thank you for the detailed information as well as the code provided. Please note that when you use external control to replace the Advanced Form - the OnClientFormCreated client-side event is not fired. That's why the settings of the recurrence editor are not applied. As an alternative you can apply the code in the pageLoad() function. Also please note that the id-s of the checkboxes are changed. They must contain the ID of the RadDock. Here's an example:

function pageLoad() {
                $telerik.$('input[id=RadDock1_C_RadSchedulerRecurrenceEditor1_WeeklyWeekDaySaturday]').attr('checked', false);
                $telerik.$('input[id=RadDock1_C_RadSchedulerRecurrenceEditor1_WeeklyWeekDaySunday]').attr('checked', false);
                $telerik.$(".rsRecurrenceOptionList li:first-child").hide();
            }

Hope this helps.

Regards,
the Telerik team

Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

0
Tiffany Phan
Top achievements
Rank 1
answered on 01 Jun 2011, 02:34 PM
Hi Veronica,

Thank you so much for your help.
I'm curious about the ID(s) of checkboxes in your example.  What does C stand for (in the following line) after the ID of the RadDock?

$telerik.$('input[id=RadDock1_C_RadSchedulerRecurrenceEditor1_WeeklyWeekDaySaturday]').attr('checked', false);

Again, thank you!

Tiffany Phan
0
Veronica
Telerik team
answered on 01 Jun 2011, 02:54 PM
Hello Tiffany,

Unfortunately I am not sure what stays behind the "C" in the id-s of the checkboxes. Maybe "C" stands for Custom as you are using a custom wrapper instead of the standart advanced form. Anyway, you only need to replace the "RadDock1" with the ID of your RadDock and everything will work OK.

Greetings,
Veronica Milcheva
the Telerik team

Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

0
Cheri
Top achievements
Rank 1
answered on 01 Jun 2011, 04:33 PM
Hello,

I am trying to hide the recurrence option that reads "Recur every _ week(s) on" that is associated with the "Weekly" recurrence radio button but I can not get the code just right, can you please tell me how I can do this?  Also, I do want to keep all the week days and the default value of recurring every 1 week.  The code I've tried so far is below:

$telerik.$(

'input[id=ctl00_SiteContentPlaceHolder_RadSchedulerRecurrenceEditor1_RecurrencePatternWeeklyPanel]'

).hide();

  

- and -


$telerik.$(

 

".rsAdvRecurrencePatterns .rsAdvOptionsPanel .rsAdvWeekly rsAdvPatternPanel"

).hide();

Neither of the above lines work and I feel like I'm just dancing around the problem. 

Thank you in advance for any help or guidance you can provide.

Cheri

 

 

0
Veronica
Telerik team
answered on 06 Jun 2011, 10:03 AM
Hi Cheri,

Pease try the following jQuery code:

function pageLoad() {
                $telerik.$(".rsAdvWeekly div:first").hide();
            }

Hope this helps.

Kind regards,
Veronica Milcheva
the Telerik team

Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

0
Cheri
Top achievements
Rank 1
answered on 06 Jun 2011, 02:50 PM
Hi Veronica,

Thank you so much!  That was exactly what I was looking for.

Cheri
0
Cynthia Stone
Top achievements
Rank 1
answered on 04 Apr 2012, 07:46 PM
Hi

I would like to know how to access the recurrence editor controls server side. I am using the advanced user control also and the form is initially created on the client (OnClientFormCreated ="schedulerFormCreated") . I am unable to access the Recurrence Editor or any of its controls. Any help would be appreciated.
   
Protected Sub RadScheduler1_FormCreated(ByVal sender As Object, ByVal e As SchedulerFormCreatedEventArgs) Handles RadScheduler1.FormCreated
        Dim scheduler As RadScheduler = DirectCast(sender, RadScheduler)
        'attachToResourceDdlEvent()
        If e.Container.Mode = SchedulerFormMode.AdvancedInsert Then
            Dim advForm As Control = DirectCast(RadScheduler1.FindControl("Form"), Control)
            Dim advUserControl As Control = DirectCast(advForm.FindControl("AdvancedInsertForm1"), Control)
            Dim advPanel As Control = DirectCast(advUserControl.FindControl("AdvancedEditOptionsPanel"), Control)
            Dim basicControlsPanel As Control = DirectCast(advPanel.FindControl("BasicControlsPanel"), Control)
            'Dim advControlsPanel As Control = DirectCast(advPanel.FindControl("AdvancedControlsPanel"), Control)
            Dim recurrenceEditor As RadSchedulerRecurrenceEditor = DirectCast(advPanel.FindControl("AppointmentRecurrenceEditor"), RadSchedulerRecurrenceEditor)
            Dim PriorityDdl As RadComboBox = DirectCast(advPanel.FindControl("PriorityCombo"), RadComboBox)
            If PriorityDdl IsNot Nothing Then
                PriorityDdl.AutoPostBack = True
                AddHandler PriorityDdl.SelectedIndexChanged, AddressOf priorityDdl_SelectedIndexChanged
            End If
            If hidShowRecurrence.Value = "TRUE" Then
                If recurrenceEditor IsNot Nothing Then
                    ''Checks the recurrence checkbox so that the recurrence editor is expanded.
                    'Dim recurrenceCheckbox As CheckBox = DirectCast(advPanel.FindControl("RecurrentAppointment"), CheckBox)
                    'recurrenceCheckbox.Checked = True
                    ''Disable Sunday for the weekly recurrence rule
                    Dim sundayCheckbox As CheckBox = DirectCast(recurrenceEditor.FindControl("WeeklyWeekDaySunday"), CheckBox)
                    sundayCheckbox.Enabled = False
                    ''Disable Saturday for the weekly recurrence rule
                    'Dim saturdayCheckbox As CheckBox = DirectCast(advPanel.FindControl("WeeklyWeekDaySaturday"), CheckBox)
                    'saturdayCheckbox.Enabled = False
                End If
            End If
            ''CHANGE THE START TIME PICKER OPTIONS
            Dim startTime As RadTimePicker = TryCast(basicControlsPanel.FindControl("StartTime"), RadTimePicker)
            ''CHANGE THE END TIME PICKER OPTIONS
            Dim endTime As RadTimePicker = TryCast(basicControlsPanel.FindControl("EndTime"), RadTimePicker)
            startTime.SelectedDate = RoundToNearestHour(Date.Now)
            endTime.SelectedDate = startTime.SelectedDate.Value.AddHours(1)
            'UPDATE THE END DATE PICKER WHEN THE START DATE PICKER IS CHANGED
            Dim startDate As RadDatePicker = TryCast(basicControlsPanel.FindControl("StartDate"), RadDatePicker)
            If Not IsNothing(startDate) Then
                startDate.ClientEvents.OnDateSelected = "changeEndDate"
            End If
            'UPDATE THE END TIME PICKER WHEN THE START TIME PICKER IS CHANGED
            If Not IsNothing(startTime) Then
                startTime.ClientEvents.OnDateSelected = "changeEndTime"
            End If
        End If
    End Sub
0
Cheri
Top achievements
Rank 1
answered on 04 Apr 2012, 08:42 PM
Hi Cynthia,

After much struggle with using the Advanced Form I decided to use an external page that I could completely customize to create/edit appointments.  On the Scheduler page I used the 'OnClientAppointmentEditing="AppointmentEditing" ' and ' OnClientAppointmentInserting="AppointmentInserting" ' in the RadScheduler properties.  If you decide to use this method you'll need to need to add the following javascript to the client:

 

function AppointmentInserting(sender, eventArgs)

 {

 

// Open up a blank edit form.
window.radopen("EditActivity.aspx?apptToEdit=" + 0, "EditForm");

 eventArgs.set_cancel(

true);

 }

 
function AppointmentEditing(sender, eventArgs)

 {

 var apt = eventArgs.get_appointment();

 if (apt._subject=="Leave Of Absence")

 {

window.radopen("EditActivity.aspx?apptToEdit=" + apt._id, "EditForm");

 }

 eventArgs.set_cancel(true);

 }

  

function refreshSched(arg)

 {

 if (!arg)

 {

$find(

"<%= RadAjaxManager1.ClientID %>").ajaxRequest("RebindScheduler");

 }

}

 

<asp:Content>
<telerik:RadAjaxManager ID="RadAjaxManager1" runat="server" OnAjaxRequest="RadAjaxManager1_AjaxRequest"/>

 <telerik:RadWindowManager ID="RadWindowManager1" runat="server" Skin="Outlook" OnClientClose="refreshScheduler">

 <Windows>

 <telerik:RadWindow ID="EditForm" runat="server" Behaviors="Close" Modal="true" InitialBehavior="None" OnClientClose="refreshScheduler" Style="display: none;" Title="Manage Individual Activites and Appointments" Skin="Office2007" height="600px" Width="550" ShowContentDuringLoad="false">

 </telerik:RadWindow>

 </Windows>

 </telerik:RadWindowManager>

 </asp:Content>

  

RadScheduler page server side:

 

#Region " RadAjaxManager1_AjaxRequest"

 ' Rebind the scheduler 

 Protected Sub RadAjaxManager1_AjaxRequest(ByVal sender As Object, ByVal e As Telerik.Web.UI.AjaxRequestEventArgs) Handles RadAjaxManager1.AjaxRequest

 If e.Argument = "RebindScheduler" Then

 RadScheduler1.Rebind()

End If

End Sub

 #End Region

 
Now as for the EditActivity.aspx page I was able to build out a page (that does not inherit from a Master Page) that has all the fields I want to populate and collect along with a recurrence editor.  In the server side code I found, then enabled/disabled the week days using the following code:

 

Protected Sub EnableFields(ByVal enableFields As Boolean)

 Dim chkSunday As CheckBox = RadSchedulerRecurrenceEditor1.FindControl("WeeklyWeekDaySunday")

Dim chkMonday As CheckBox = RadSchedulerRecurrenceEditor1.FindControl("WeeklyWeekDayMonday")

Dim chkTuesday As CheckBox = RadSchedulerRecurrenceEditor1.FindControl("WeeklyWeekDayTuesday")

Dim chkWednesday As CheckBox = RadSchedulerRecurrenceEditor1.FindControl("WeeklyWeekDayWednesday")

Dim chkThursday As CheckBox = RadSchedulerRecurrenceEditor1.FindControl("WeeklyWeekDayThursday")

Dim chkFriday As CheckBox = RadSchedulerRecurrenceEditor1.FindControl("WeeklyWeekDayFriday")

Dim chkSaturday As CheckBox = RadSchedulerRecurrenceEditor1.FindControl("WeeklyWeekDaySaturday")

 

' Sets the check mark value for the week day check boxes

chkSunday.Enabled = enableFields

chkMonday.Enabled = enableFields

chkTuesday.Enabled = enableFields

chkWednesday.Enabled = enableFields

chkThursday.Enabled = enableFields

chkFriday.Enabled = enableFields

chkSaturday.Enabled = enableFields

End Sub

' Change the recurrence start/end times
Dim xStartTime As String = Convert.ToDateTime(StartTime.SelectedDate).TimeOfDay.ToString()

Dim xEndTime As String = FormatDateTime(EndTime.SelectedDate.Value.TimeOfDay.ToString, DateFormat.LongTime)

Dim startDateTime = FormatDateTime(Ind_StartDate.SelectedDate + " " + xStartTime, DateFormat.GeneralDate)

Dim endDateTime = FormatDateTime(Ind_StartDate.SelectedDate + " " + xEndTime, DateFormat.GeneralDate)

Dim start As DateTime = startDateTime

Dim [end] As DateTime = endDateTime

RadSchedulerRecurrenceEditor1.StartDate = startDateTime

RadSchedulerRecurrenceEditor1.EndDate = endDateTime

 

' Note: If you find that you have to manually manipulate the recurrance rule that can be done by converting the rule to text then parsing through it, but doing so is a real pain in the butt!  Unfortunately, I was left with no other option due to way in which I need to use the scheduler. 

Hope this helps,

Cheri




Tags
Scheduler
Asked by
Tiffany Phan
Top achievements
Rank 1
Answers by
Veronica
Telerik team
Tiffany Phan
Top achievements
Rank 1
Cheri
Top achievements
Rank 1
Cynthia Stone
Top achievements
Rank 1
Share this question
or