Domanda

With KendoUI 2013.3.1109

I am using KendoUI's scheduler

I am using a template for the reservation form, but via googling and perusing the forums, I read about re-using their recurrence form. I even figured out via experimenting that one could select which period options are available by, for instance, running:

$("#recurrenceEditor").kendoRecurrenceEditor(
    {
      frequencies: ["never", "daily", "weekly", "monthly"]
    }); 
});

The code above will not load the 'yearly' option in the drop down. There is no API documentation for kendoRecurrenceEditor on the website, but I was wondering if it is possible to tweak additional options, like removing the 'never' tag on when a recurrence should expire and so on.

È stato utile?

Soluzione

So I initialize the Kendo recurrence editor:

 $("#recurrenceEditor").kendoRecurrenceEditor({
            change: function() {
                onRecurrenceEditorChange();
            }
  });

Then I tweak what's visible inside #recurrenceEditor

var onRecurrenceEditorChange = function() {
            var recurrenceKendoNumericTextBox = $('#recurrenceEditor .k-widget.k-numerictextbox.k-recur-count input[data-role="numerictextbox"]')
                .data('kendoNumericTextBox');

            if (recurrenceKendoNumericTextBox != null) {

                var recurrenceEditorNeverEndOption = _container.find('#recurrenceEditor label:has(.k-recur-end-never)');

                if (recurrenceEditorNeverEndOption != null)
                    recurrenceEditorNeverEndOption.hide();

                recurrenceKendoNumericTextBox.max(10);

                var recurrenceKendoDatePicker = _container.find('#recurrenceEditor .k-datepicker input[data-role="datepicker"]').data("kendoDatePicker");
                if (recurrenceKendoDatePicker != null) {
                    var maxDate = window.moment().add('months', 2).toDate();
                    recurrenceKendoDatePicker.max(maxDate);
                    recurrenceKendoDatePicker.value(maxDate);
                }
            }
        };

Then if you want to tweak the intervals, hack around it this way:

var recurrencePeriodKendoDropDownList = $('.k-widget.k-dropdown input[data-role="dropdownlist"]').data("kendoDropDownList");
        var recurrencePeriodFilters = [
            {
                field: "value",
                operator: "neq",
                value: 'yearly'
            }, {
                field: "value",
                operator: "neq",
                value: 'monthly'
            },
            // if it's a newres, don't hide 'Never' option which matches to "", 
            {
                field: "value",
                operator: "neq",
                value: someBoolConditionIhave ? "fake" : ""
            }
        ];
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top