在部分视图上的网格中Kendo Dropdownlist的UHint失败.Net Core

时间:2019-07-12 17:23:21

标签: .net kendo-grid core kendo-dropdown

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

架构:
视图-> 带有网格的弹出窗口视图,编辑模式为“内联”

我在网格中有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; }
    }
}

感谢您的帮助。

我遵循了Telerik的演示。

1 个答案:

答案 0 :(得分:0)

问题在于获取下拉列表数据的方法。 在代码文件中,id和name字段分别是string和integer,但是我正在将string和string加载到控件中。那打破了它。 因此,请确保您的ID和名称等数据类型,或您所说的任何数据类型,都与您在下拉列表中定义它们的方式一致。