Question

I have below kendo scheduler code in my .Cshtml page

<div class="space-6"></div>
    <div class="row">
      <label>Procedure Code</label>
        @Html.Partial("Partials/_ProviderCodeHint")
  </div>

@(Html.Kendo().Scheduler<AppoinmentModel>()
    .Name("AppoinmentModelSchduler")
    .Views(views =>
    {
        views.DayView();
        views.WorkWeekView(workWeekView => workWeekView.Selected(true));
        views.WeekView();
        views.MonthView();
        views.AgendaView();
    })
    .Resources(resource =>
    {
        resource.Add(m => m.ProcedureCode_Id)
             .Title("Pro Code")
             .DataTextField("DisplayText")
             .DataValueField("DataField")
             .Name("ProcedureCode_Id")
             .DataSource(p => p.Read(x => x.Action("GetProcedureCodes", "OfficeAppointment").Data("_ProviderCodeHint_SupplementData")).ServerFiltering(true));
    })
    .DataSource
    (
         d => d.Model(m =>
         {
             m.Id(f => f.Id);
             m.Field(f => f.Title).DefaultValue("No title");
             m.RecurrenceId(f => f.RecurrenceId);
         })
        .Events(x => x.Error("kendoGridErrorHandle"))
        .ServerOperation(true)
        .PageSize(500)
        .Read(x => x.Action("Scheduler_Appointment_Read", "OfficeAppointment").Data("Scheduler_SupplementData"))
        .Create(x => x.Action("Scheduler_Appointment_AddUpdate", "OfficeAppointment").Data("Scheduler_SupplementData"))
        .Update(x => x.Action("Scheduler_Appointment_AddUpdate", "OfficeAppointment").Data("Scheduler_SupplementData"))
        .Destroy("Scheduler_Appointment_Delete", "OfficeAppointment")
    )
)

I'm binding Drop down by calling another partial view.

The Partial view Code

<script>

    function _ProviderCodeHint_SupplementData() {
        var providerCodeCombo = $("#_ProviderCodeHint").data("kendoDropDownList");

        return {
            ProviderCodeId: providerCodeCombo.value()
        };
    }

    function providerCodeHintOnChange() {
        alert('Tested');
    }

</script>

@(
 Html.Kendo().DropDownList()
        .Name("_ProviderCodeHint")
        .HtmlAttributes(new { @class = "input-xlarge" })
        .DataValueField("DataField")
        .Events(x => x.Change("providerCodeHintOnChange"))
        .DataTextField("DisplayText")
        .DataSource(p => p.Read(x => x.Action("GetProcedureCodes", "OfficeAppointment").Data("_ProviderCodeHint_SupplementData")).ServerFiltering(true))
)

Evert hing works good. But when i try to add a drop down list events. Its not getting fired. I have tried Jquery and .Events of kendo.

if i use .Events of kendo its getting triggered when the Resource is loading time itself.

Guide me to Trigger an onchange event inside popup after loading popup from the click of Scheduler cell onclick.

Right now Jquery is not working for the Onchange due to loading priority.

Was it helpful?

Solution

Myself found the Solution.,

While loading Scheduler there itself i have called script function and initialized events .Events(eve => eve.Change("OnLoad")

In Partial View:

.DataSource
    (
         d => d.Model(m =>
         {
             m.Id(f => f.Id);
             m.Field(f => f.Title).DefaultValue("No title");
             m.RecurrenceId(f => f.RecurrenceId);
         })
        .Events(x => x.Error("kendoGridErrorHandle"))
        .ServerOperation(true)
        .PageSize(500)
        .Read(x => x.Action("Scheduler_Appointment_Read", "Appointment").Data("Scheduler_SupplementData")).Events(eve => eve.Change("OnLoad"))
        .Create(x => x.Action("Scheduler_Appointment_AddUpdate", "Appointment").Data("Scheduler_SupplementData"))
        .Update(x => x.Action("Scheduler_Appointment_AddUpdate", "Appointment").Data("Scheduler_SupplementData"))
        .Destroy("Scheduler_Appointment_Delete", "Appointment")
    )

In Script:

function OnLoad() {
        $('select[data-bind="value:ProcedureCode_Id"]').change(function () {
            $('input[data-bind="value:title"]').val($('select[data-bind="value:Provider_Id"]')[0].selectedOptions[0].text + ", " + $('select[data-bind="value:ProcedureCode_Id"]')[0].selectedOptions[0].text);

        });

        $('select[data-bind="value:Provider_Id"]').change(function () {
            $('input[data-bind="value:title"]').val($('select[data-bind="value:Provider_Id"]')[0].selectedOptions[0].text + ", " + $('select[data-bind="value:ProcedureCode_Id"]')[0].selectedOptions[0].text);

        });
    }
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top