4

I am having trouble to hide one option in recurrence editor in a standardized way. I have tried to hide it by custom code but it sometimes creates not predictable behaviour.

This is what I am trying to hide:

enter image description here

Jakub Holovsky
  • 6,543
  • 10
  • 54
  • 98

3 Answers3

7

You need to handle the edit event of the scheduler and hide that option via jQuery:

function scheduler_edit(e) {
  // find the recurring dropdownlist 
  var dropdown = e.container.find("[data-role=dropdownlist]").data("kendoDropDownList");

  // handle its change event
  dropdown.unbind("change", hide_never);
  dropdown.bind("change", hide_never);
}

function hide_never() {
  // hide the <li> element that contains the "Never" radio option
  $(".k-recur-end-never").closest("li").hide();
}
Atanas Korchev
  • 30,562
  • 8
  • 59
  • 93
  • I had added other dropdowns in my custom editor template so the above code did not find the recurrence editor dropdown. Instead I needed to use `e.container.find("[data-role=recurrenceeditor]")` – sonyisda1 Feb 23 '17 at 20:11
2

You also could make this:

in the edit event of the widget:

  var recurrenceEditor = e.container.find("[data-role=recurrenceeditor]").data("kendoRecurrenceEditor");     

            //set start option value, used to define the week 'Repeat on' selected checkboxes
            recurrenceEditor.setOptions({
                start: new Date(e.event.start),
                change: function (e) { onRecurrenceEditor_Change(e,this); }
            });

and then:

 function onRecurrenceEditor_Change(e, obj) {
        var buttonNever = obj._buttonNever;

        if (buttonNever) {
            $(buttonNever[0]).parent().remove();
        }
    }
yBother
  • 648
  • 6
  • 25
1

I just got a response from Telerik's support, which I pay for. Splice the dropdown's data and re-set it:

edit: function (e) {
    // remove Yearly" from re-occurence dropdown
    var ddl = $('input[title="Recurrence editor"]').data('kendoDropDownList');
    if (ddl) {
      var data = ddl.dataSource.data();
      data = data.slice(0, 4);
      ddl.setDataSource(data);
    }
},

Working Dojo.

xinthose
  • 3,213
  • 3
  • 40
  • 59
  • This does not solve the question which is regarding the removal of the "never" option. The snipped you provided will only remove 'Yearly' from the dropdown list. – Amacado Dec 14 '20 at 18:38
  • @Amacado right; just use `data.slice(1)` instead then; you are just manipulating the array; they no longer use an array in the 2020 version though – xinthose Dec 14 '20 at 20:17