I have a custom edit template for kendo scheduler. Below all the controls to set dates and the recurrence rule I have a button. Pressing the button loads a list of people available for that appointment. To get that list, I am checking conflicts in future visits and I'm checking against a people availability table to make sure they are available on those dates.
All the code works fine except I cannot get the recurrence rule before the Save button is pressed and the data is transported to the server.
The recurrenceRule property is blank even though all the selections are made before pressing my button.
It seems kendo scheduler formats that recurrence rule when you press the save button and then populates the model and transports it to the server.
I could write my own Recurrence Rule by reading the widgets in the kendo recurrence editor control but they didn't put an Id's on the widgets which makes them hard to get. I think you can use css selectors but I haven't done anything like that and would rather not write my own recurrence editor.
Does anyone know how to get the recurrence rule while in the edit template before pressing Save?
FLOW:
1) set start and end date, and recurrence pattern in kendo recurrence editor
2) press button on edit template form to load available employees --- I need the recurrence rule here. On the server side I expand the appointment to all it's occurrences and then I check each potential visit against the employee schedule
3) select one of the employees and save the record. --- I can't do the check here because the employee has to be selected before saving the record and I only want to provide a list of available employees -- before save.
I tried many things including this:
var recurEditor = $("#RecurrenceRule").data("kendoRecurrenceEditor");
var recurrenceRule = recurEditor.options.recurrenceRule;
alert("recurrenceRule: " + recurrenceRule);
But no luck...
Here's the solution. I knew if I posted the question here, after 2 days of trying to figure it out, that I'd find the solution. Maybe this will help someone else.
On the handler for my button to load available employees, I have this code:
var ruleEditor = $('[id="RecurrenceRule"]').getKendoRecurrenceEditor();
if (ruleEditor) {
vRecurRuleValue = ruleEditor.value();
alert("vRecurRuleValue = " + vRecurRuleValue);
}
My recurrence editor is defined in my edit template as so:
@(Html.Kendo().RecurrenceEditorFor(model => model.RecurrenceRule).HtmlAttributes(new { data_bind = "value:recurrenceRule", data_role = "recurrenceEditor" } ))And my employee dropdown has a filter as follows:
<div id="EmpAssignedDropdownlist" class="k-edit-field" style="visibility:hidden;">
@(Html.Kendo().DropDownListFor(m => m.VisitEmployeeM.UserId)
.AutoBind(false)
.Text("Please Select") //used to prevent initial datasource.read as AutoBind doesn't work
.DataTextField("name")
.DataValueField("id")
.ValuePrimitive(true)
.OptionLabel(@Localizer["Please Select"].Value)
.DataSource(source =>
{
source.Read(read =>
{
read.Action("GetEmployeesAvailableForPotentialVisit", "DropDownList").Data("filterAvailableEmployeesNoVisitYet");
}).ServerFiltering(true);
})
)
</div>
the javascript function "filterAvailableEmployeesNoVisitYet" passes the recurrence rule and other data I need to check for conflicts and loads the dropdownlist.