Controlling RecurrenceEditor.

8 posts, 1 answers
  1. Answer
    Pär Sandgren
    Pär Sandgren avatar
    7 posts
    Member since:
    Dec 2013

    Posted 18 Dec 2013 Link to this post

    Hi there,

    I would like to disable or remove the <li> containing the "never" radiobutton, to force the user to set an end for the task. I managed to do this on the edit-event, but only for existing tasks. When I tried to hook the "change"-event of the recurrenceEditor, I couldn't get the selector $(':radio[value="never"]') to work. This part is undocumented, and a bit hard to "guess". Anyone got a hint?

    Some example code:
    01.<div data-container-for="recurrenceRule" class="k-edit-field">
    02.    <div data-bind="value:recurrenceRule" id="recurrenceEditorDiv"></div>
    03.    <script>
    04.        $(function() {
    05.            $("\#recurrenceEditorDiv").kendoRecurrenceEditor(
    06.            {
    07.                frequencies: ["never", "weekly"],
    08.                change: function(e) {
    09.                    // This would be nice if it worked
    10.                    var rb = e.container.find(".k-recur-end-never");
    11.                    rb.attr('disabled', 'disabled');
    12. 
    13.                    // Or this. This works in the grid's "edit"-event
    14.                    var li = e.container.find(".k-recur-end-never")
    15.                                        .parent()
    16.                                        .parent();
    17.                    li.remove();
    18.                },
    19.                messages: {
    20.                    end: {
    21.                        after: " efter ",
    22.                        occurrence: " händelse(r)",
    23.                        label: "Slut",
    24.                        never: " aldrig",
    25.                        on: " på "
    26.                    },
    27.                    frequencies: {
    28.                        weekly: "per vecka",
    29.                        never: "aldrig",
    30.                    },
    31.                    offsetPositions: {
    32.                        first: "första",
    33.                        second: "andra",
    34.                        third: "tredje",
    35.                        fourth: "fjärde",
    36.                        last: "sista"
    37.                    },
    38.                    weekly: {
    39.                        interval: " vecka(or)",
    40.                        repeatEvery: "Intervall",
    41.                        repeatOn: "Dagar "
    42.                    },
    43.                    weekdays: {
    44.                        day: "Dag",
    45.                        weekday: "Veckodag",
    46.                        weekend: "Helgdag"
    47.                    }
    48.                }
    49.            });
    50.        });
    51.    <\/script>
    52.</div>
  2. Georgi Krustev
    Admin
    Georgi Krustev avatar
    3748 posts

    Posted 19 Dec 2013 Link to this post

    Hello Par,

    In general, the recurrence editor is not designed to allow control over end pattern. I will suggest you open a user voice discussion on this subject, as this is will be a great way to gather community feedback about that functionality.

    If this is a must for you to stop the never  option then you can hide/disable the first radio button like it is shown here. Please note that the suggested approach is a custom solution and I cannot guarantee it will work in future releases. 

    Regards,
    Georgi Krustev
    Telerik
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
  3. Pär Sandgren
    Pär Sandgren avatar
    7 posts
    Member since:
    Dec 2013

    Posted 19 Dec 2013 Link to this post

    Thank you Georgi!

    This solution is more than enough. This is for a very special solution, for a special customer. My personal thought of this being stupid idea wasn't enough for them so I guess they will have to live with it. Hopefully I won't have to do this again.

    // Pär
  4. Simon
    Simon avatar
    35 posts
    Member since:
    Mar 2016

    Posted 26 Jan 2018 Link to this post

    Resurrecting an old thread here but is this still the only/recommmended way to hide the Never radio button for the end pattern in the recurrence editor? It would be great if there was a declarative way of doing this similar to the frequency options:

     

    <div data-container-for="recurrenceRule" class="k-edit-field">
        @(Html.Kendo().RecurrenceEditorFor(model => model.RecurrenceRule)
            .HtmlAttributes(new { data_bind = "value:recurrenceRule" })
            .Frequency(frequency => frequency
                .Add(RecurrenceEditorFrequency.Never)
                .Add(RecurrenceEditorFrequency.Daily)
                .Add(RecurrenceEditorFrequency.Weekly)
                .Add(RecurrenceEditorFrequency.Monthly)
                )
            )
    </div>

     

    Similar to the OP, it's more of a user issue here, we really don't want some one to pick a recurrence of Daily and an end of Never! 

    Thanks.

    Simon

     

  5. Neli
    Admin
    Neli avatar
    221 posts

    Posted 30 Jan 2018 Link to this post

    Hello Simon,

    I am afraid, that there is no built-in functionality to achieve the desired appearance. If you need to hide the 'Never' option for recurrence end, you could follow the example suggested previously in this thread.

    Another suggestion is described in the following link from StackOverflow. For your convenience I prepared a Dojo example based on the sample code in the link. I hope you will find it helpful.

    Regards,
    Neli
    Progress Telerik
    Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
  6. Simon
    Simon avatar
    35 posts
    Member since:
    Mar 2016

    Posted 16 Feb 2018 in reply to Neli Link to this post

    Thanks Neli, works great.
  7. Simon
    Simon avatar
    35 posts
    Member since:
    Mar 2016

    Posted 08 Mar Link to this post

    Neli, can you set the "After" radio button to be default selected after hiding the "Never" radio button for Daily/Weekly/Monthly/Yearly options? As it is now radio button is selected ("After or End") which confuses our users, they have been selecting neither radio button...

     

    Thanks.

  8. Dimitar
    Admin
    Dimitar avatar
    667 posts

    Posted 12 Mar Link to this post

    Hello Simon,

    You could achieve the desired result as follows:
    function onRecurrenceEditor_Change(e, obj) {
      var buttonNever = obj._buttonNever;
      var buttonCount = obj._buttonCount;
           
      if (buttonNever) {
        $(buttonNever[0]).parent().remove();
      }
       
      if(buttonCount) {  
        buttonCount.parent().click();
      }
    }

    Here is an updated Dojo example that demonstrates the above.

    Regards,
    Dimitar
    Progress Telerik
    Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Back to Top