Hide "No End Date" option in Recurrence Editor

6 posts, 2 answers
  1. Robert
    Robert avatar
    7 posts
    Member since:
    Jun 2010

    Posted 17 Mar 2011 Link to this post

     

    In the Telerik Recurrence Editor control I want to hide "No End Date" while leaving "End After" and "End By".  I can't allow my clients the ability to make recurring reservations with no end date.

    I was able to hide the option button by finding the id of the control but there is no id for the label of that option button.  So, I can hide the radio button but not the label for it.

    Can anyone provide some code for this?

    One work around would be to validate that the No End Date option is not selected after post back but I'd rather not do that.

    Thanks,
    Rob

     

     



     



  2. Robert
    Robert avatar
    7 posts
    Member since:
    Jun 2010

    Posted 17 Mar 2011 Link to this post


    If anyone is able to hide these controls via client side I'd still like to know how.

    --

    Since I wasn't able to hide the control (for now), I created the following validation controls as a work around.

    Client Side >>

     

     

     

    <asp:CustomValidator ID="validateRecurrenceUntil" runat="server" Display="Dynamic"
        ForeColor="red" ErrorMessage="* Recurrence until date must be greater than conference end date. <br/>"
        OnServerValidate="ValidateRecurrenceUntil" />
    <asp:CustomValidator ID="validateRecurrenceNoEndDate" runat="server" Display="Dynamic"
            ForeColor="red" ErrorMessage="* Recurrence cannot be indefinite. <br/>"
            OnServerValidate="ValidateRecurrenceNoEndDate" />


    Server Side >>

    With my configuration I implemented my own check box for Recurrence and hide the built in one.

    protected void ValidateRecurrenceUntil(Object source, ServerValidateEventArgs args)
    {
        args.IsValid = true;
        try
        {
            if (this.chkRecurrence.Checked)
            {
                if (this.RecurrenceEditor1.RecurrenceRule.Range.RecursUntil < this.CalculateEnd())
                {
                    args.IsValid = false;
                    upWizard.Update();
                }
            }
        }
        catch (System.Exception ex)
        {
            args.IsValid = true;
            upWizard.Update();
        }
    }
    protected void ValidateRecurrenceNoEndDate(Object source, ServerValidateEventArgs args)
    {
        args.IsValid = true;
        DateTime dteNoEndDate = Convert.ToDateTime("12/31/9999");
        try
        {
            if (this.chkRecurrence.Checked)
            {
                if (this.RecurrenceEditor1.RecurrenceRule.Range.RecursUntil >= dteNoEndDate)
                {
                    args.IsValid = false;
                    upWizard.Update();
                }
            }
        }
        catch (System.Exception ex)
        {
            args.IsValid = true;
            upWizard.Update();
        }
    }


  3. Answer
    Veronica
    Admin
    Veronica avatar
    1213 posts

    Posted 17 Mar 2011 Link to this post

    Hi Robert,

    You can easily remove the "No End Date" label and radiobutton by suscribing to the OnClientFormCreated event and using the following jQuery code in the handler:

    <script type="text/javascript">
           function OnClientFormCreated(sender, eventArgs) {
               $telerik.$(".rsAdvOptionsPanel ul li:first-child").hide();
           }
       </script>


    All the best,
    Veronica Milcheva
    the Telerik team
  4. Robert
    Robert avatar
    7 posts
    Member since:
    Jun 2010

    Posted 17 Mar 2011 Link to this post


    Thanks for your quick reply, yes that works great, just what I wanted. 
  5. Robert
    Robert avatar
    7 posts
    Member since:
    Jun 2010

    Posted 18 Mar 2011 Link to this post


    Hi Veronica,

    Unfortunately, your solution is also hidding the Daily: Every [1] day(s) option as well.  This is an option I want to display.

    The yearly and monthly options are also missing their first elements. 

  6. Answer
    Peter
    Admin
    Peter avatar
    6637 posts

    Posted 19 Mar 2011 Link to this post

    Hi Robert,

    Here is a more specific selector:
    <script type="text/javascript">
          function OnClientFormCreated(sender, eventArgs) {
              $telerik.$(".rsAdvRecurrenceRangePanel .rsAdvOptionsPanel ul li:first-child").hide();
          
      </script>


    Kind regards,
    Peter
    the Telerik team
Back to Top