如何在Kendo调度程序资源(Popup)中触发DropDownList事件

时间:2014-03-03 12:35:57

标签: c# kendo-ui kendo-grid kendo-asp.net-mvc kendo-scheduler

我的.Cshtml

中有以下的剑道调度程序代码
<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")
    )
)
  

我正在绑定通过调用另一个局部视图下拉。

部分视图代码

<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运作良好。但是当我尝试添加下拉列表事件时。它没有被解雇。我尝试了剑道的Jquery.Events

如果我使用剑道.Events,那么当资源加载时,它就会被触发。

指导我在点击Scheduler cell onclick加载弹出窗口后触发onchange event内部弹出窗口。

由于加载优先级,目前Jquery不适用于Onchange

1 个答案:

答案 0 :(得分:1)

我自己找到了解决方案。,

加载Scheduler时,我已拨打script function and initialized events .Events(eve => eve.Change("OnLoad")

在部分视图中

.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")
    )

在剧本中:

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);

        });
    }