Telerik Kendo Grid不会向Controller发送列值

时间:2016-08-19 13:19:50

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

我使用带有使用此Kendo Grid的Visual Studio 2012项目的Entity Framework处理ASP.NET MVC(C#,razor):

@(Html.Kendo().Grid<Procedure>()
                            .Name("ProcedureGrid")
                            .Columns(columns =>
                            {                                
                                columns.Bound(d => d.DateLocal)
                                    .Format("{0:" + ELSORegistry.Helpers.Html.GetDateFormatString() + " " + ELSORegistry.Helpers.Html.GetTimeFormatStringWithoutSeconds() + "}")
                                    .Title(RunStrings.DateTime)
                                    .EditorTemplateName("proceduresDateLocal");                                
                                columns.Bound(d => d.DateEstimated).Title(RunStrings.Est)
                                   .Width(35).ClientTemplate(
                                    "<input type='checkbox' value='#= DateEstimated #' disabled " +
                                        "# if (DateEstimated) { #" +
                                            "checked='checked'" +
                                        "# } #" +
                                    " />"
                                );
                                columns.Bound(d => d.ICD10Code).Title(RunStrings.ICD10PCSCode).EditorTemplateName("ICD10PCSCode");
                                columns.Bound(d => d.ICD10PCSDescription).Title(RunStrings.Procedure);//.EditorTemplateName("Blank");
                                columns.Bound(d => d.CPTOldShortDescription).Title("CPT").Width(250); // .ClientTemplate("#=CPTCodeDescription#")
                                columns.Command(command => { command.Edit().UpdateText(RunStrings.Save); command.Destroy(); }).Width(180);
                            })
                            //.Events( e => e.Edit("ProcedureGrid_OnEdit").DataBound("onDataBound") )
                            .Events( e => e.Edit("ProcedureGrid_OnEdit").Cancel("ProcedureGrid_OnCancel").Save("ProcedureGrid_OnSave"))
                            .Editable(editable => editable.Mode(GridEditMode.InLine))
                            .ToolBar(toolbar => toolbar.Create().Text(RunStrings.AddNewProcedure))
                            .Sortable()
                            .DataSource(ds => ds
                                .Ajax()
                                .Batch(false)
                                        .Model(model => 
                                        { 
                                            model.Id(field => field.ProcedureId);
                                            //model.Field(field => field.CPTCodeDescription).Editable(false);
                                        })
                                .Events(events => events.Error("error").RequestEnd("requestEnd"))
                                .Read(read => read.Action("ReadProcedures", "Run"))
                                .Create(create => create.Action("CreateProcedure", "Run"))
                                .Update(update => update.Action("UpdateProcedure", "Run"))
                                .Destroy(destroy => destroy.Action("DeleteProcedure", "Run"))
                                .Sort(order =>
                                {
                                    order.Add(y => y.PrimaryProcedure).Descending();                                   
                                })))

列ICD10Code有一个模板:

@(Html.Kendo().AutoCompleteFor(model => model)
        .Name("ICD10Code")
        .Placeholder(RunStrings.TypeICD10PCS)
        .MinLength(3)
        .Delay(300)
        .DataTextField("DisplayText")
        .DataSource(source =>
            source.Read(read =>
                read.Action("GetProcedureList", "Run", new { area = "ECLS"})
                    .Data("onAdditionalData")
                )
                .ServerFiltering(true)
        )
        .HtmlAttributes(new { title = RunStrings.TypeICD10PCSDescription})
        )

该列称为“CPT”,在模型的扩展名中定义为:

public string CPTOldShortDescription
        {
            get
            {
                return this.CPTCode == null ? string.Empty : this.LookForCPTCode();
            }
        }
        private string LookForCPTCode()
        {
            string retVal = string.Empty;

            if (this.CPTCode.Length > 0)
            {
                CPTCodes cpt = (new Repository()).GetCPTCode(this.CPTCode);

                if (cpt != null)
                {
                    retVal = string.Format("{0} {1}", cpt.CPTCode, cpt.Description);
                }

            }
            return retVal;

        }

我在网格中执行“更新”时遇到问题。当列CPT为空时,一切正常。当我在CPT列中有内容时,Kendo网格不会发送“ICD10Code”列,并且更新不起作用。我怎么解决这个问题?提前感谢您的帮助。

0 个答案:

没有答案