Kendo 网格中部分视图下拉列表的 UHint 失败 .Net Core

UHint for Kendo Dropdownlist in Grid on Partial View Fails .Net Core

Whosebug 中有很多关于 kendo 网格中的下拉列表的条目,但我找不到解决这个问题的条目。

架构:
View --> popup window view with grid,编辑模式“InLine”

我有 3 个字段需要网格中的下拉列表。 我在模型上使用 UIHint 属性来呈现这些下拉菜单

当加载弹出窗口时,网格按原样显示,但是当我去编辑订单项时(编辑模式:GridEditMode.InLine),我收到 javascript 错误:无效令牌或符号,网格不会进入编辑模式。

如果我注释掉 UIHint 属性,网格将进入编辑模式。如果我取消注释这三个中的任何一个,它将因无效令牌错误而失败。

Kendo 体系结构中是否存在阻止下拉列表在局部视图中呈现在网格中的错误?

这是我的弹出视图:

<div style="width:700px;">
                @(Html.Kendo().Grid<xxy.Models.AgencyBillingRateModel>()
                .Name("AgencyBillingRateGrid")
                .AutoBind(false)
                .HtmlAttributes("width:700px")
                .Columns(columns =>
                {
                    columns.Command(command => { command.Edit().Text(@Localizer["Edit"].Value); command.Destroy().Text(@Localizer["Destroy"].Value); }).Width(150);
                    columns.Bound(workItem => workItem.Discipline).Width(150);
                    columns.Bound(workItem => workItem.VisitType).Width(150);
                    columns.Bound(workItem => workItem.PayCode).Width(150);
                    columns.Bound(workItem => workItem.PayCodeCondition).Width(250);
                    columns.Bound(workItem => workItem.BillingRate).Width(150);
                    columns.Bound(workItem => workItem.BillingMinutes).Width(150);
                    columns.Bound(workItem => workItem.GraceMinutesMinimum).Width(200);
                    columns.Bound(workItem => workItem.PerMileTravelReimb).Width(170);
                    columns.Bound(workItem => workItem.DefaultSurcharge).Width(170);
                })
                .ToolBar(toolbar =>
                {
                    toolbar.Create().Text(@Localizer["NewRecord"].Value);
                })
                .Events(e => e.Edit("onEditAgencyBillingRate"))
                .Events(e => e.Save("onSaveAgencyBillingRate"))
                .HtmlAttributes(new { style = "height:400px;" })
                //.Editable(ed => ed.Mode(GridEditMode.InLine)) //.TemplateName("PractitionerTemplate").Window(w => w.Title(@Localizer["Edit Medical Provider"].Value).Name("editWindow").HtmlAttributes(new { id = "editWindow", @width = "700px" })))
                .Pageable(pageable => pageable
                .Refresh(true)
                .PageSizes(true)
                .ButtonCount(5))
                .Navigatable()
                .Sortable()
                .Scrollable(src => src.Height(400))
                .DataSource(dataSource => dataSource
                    .Ajax()
                    .PageSize(20)
                    .Events(events => events.Error("AGBError_handler"))
                    .Model(m =>
                    {
                        m.Id(p => p.AgencyBillingRateId);
                        m.Field(p => p.AgencyBillingRateId).Editable(false);
                    })
                    .Create(create => create.Action("AgencyBillingRateCreate", "AgencyBillingRate"))
                    .Read(read => read.Action("AgencyBillingRateRead", "AgencyBillingRate").Data("LoadAgencyBillingRate"))
                    .Update(update => update.Action("AgencyBillingRateUpdate", "AgencyBillingRate"))
                    .Destroy(delete => delete.Action("AgencyBillingRateDelete", "AgencyBillingRate"))
                    )
                )
                <br /><br />
            </div>

这是三个下拉菜单之一;存储在 Views/Shared/EditorTemplates

@model HomeCare2.Models.AgencyBillingRateModel
@(Html.Kendo().DropDownListFor(m => m)
      .HtmlAttributes(new { style = "width: 100" })
      .DataTextField("name")
      .DataValueField("id")
      .OptionLabel(@Localizer["Please Select"].Value)
      .DataSource(source =>
          {
             source.Read(read =>
             {
               read.Action("GetAgencyBillingMinutes", "DropDownList");
             });
          })
)

这是模型:

using System;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;

namespace xxy.Models
{
    public class AgencyBillingRateModel
    {
        [Display(Name = "Agency Billing Rate Id")]
        public int AgencyBillingRateId { get; set; }

        [Display(Name = "Provider")]
        public string ProviderId { get; set; }

        [Display(Name = "Agency")]
        public string AgencyId { get; set; }

        //[UIHint("DisciplineNVL")]
        [Display(Name = "Discipline")]
        public string Discipline { get; set; }

        //[UIHint("VisitTypeNVL")]
        [Display(Name = "Visit Type")]
        public string VisitType { get; set; }

        [Display(Name = "Billing Rate Code")]
        public string PayCode { get; set; }

        [Display(Name = "Billing Rate Condition")]
        public string PayCodeCondition { get; set; }

        [DisplayFormat(DataFormatString = "{0:n2}", ApplyFormatInEditMode = true)]
        [Display(Name = "Billing Rate")]
        public decimal BillingRate { get; set; }

        //[UIHint("AgencyBillingMinutesDDL")]
        [Display(Name = "Billing Minutes")]
        //[DisplayFormat(DataFormatString = "{0}", ApplyFormatInEditMode = true)]
        public int BillingMinutes { get; set; }

        [Display(Name = "Default Surcharge")]
        [DisplayFormat(DataFormatString = "{0:n2}", ApplyFormatInEditMode = true)]
        public decimal DefaultSurcharge { get; set; }

        [Display(Name = "Per Mile Travel Reimbursement")]
        [DisplayFormat(DataFormatString = "{0:n2}", ApplyFormatInEditMode = true)]
        public decimal PerMileTravelReimb { get; set; }

        [Display(Name = "Minimum Grace Minutes")]
        [DisplayFormat(DataFormatString = "{0}", ApplyFormatInEditMode = true)]
        public int GraceMinutesMinimum { get; set; }

        [Display(Name = "Date Created")]
        [DisplayFormat(ApplyFormatInEditMode = true, DataFormatString = "{0:MM/dd/yy hh:mm}")]
        public DateTime? CreatedDate { get; set; }

        [Display(Name = "Created By")]
        public string CreatedBy { get; set; }

        [Display(Name = "Date Updated")]
        [DisplayFormat(ApplyFormatInEditMode = true, DataFormatString = "{0:MM/dd/yy hh:mm}")]
        public DateTime? UpdatedDate { get; set; }

        [Display(Name = "Updated By")]
        public string UpdatedBy { get; set; }
    }
}

问题出在获取下拉列表数据的方法上。 在代码文件中,id和name字段分别是string和integer,但是我是把string和string加载到控件中。那打破了它。 因此,请确保您的 id 和 name 数据类型,或者您对它们的称呼,与您在下拉列表中定义它们的方式一致。