Kendo Grid编辑弹出复杂模型提交

时间:2014-07-27 11:14:39

标签: asp.net-mvc kendo-ui kendo-grid

我正在尝试使用带有Kendo网格编辑弹出窗口的复杂模型。提交ALResults时,对象属性始终为null。当我不使用Kendo时,它工作正常。剑道复杂模型提交有问题吗?

public class InitialApplicantLevel2Model
    {
        public InitialApplicantLevel2Model()
        {

            alResultsModel = new ALResults();
        }

        public int InitialApplicantLevel2ID { get; set; }
        public string ApplicantName { get; set; }
        public string ContactNumber { get; set; }
        public string School { get; set; }

        [Required(ErrorMessage="Ref No. required.")]
        public int? EnquiryID { get; set; }



        public ALResults alResultsModel { get; set; }




    }

public class ALResults
    {
        public int ResultsID { get; set; }
        public int InitialApplicantLevel2ID { get; set; }
        public string Stream { get; set; }
        public string Grading { get; set; }
        public string IndexNo { get; set; }
        public int? Year { get; set; }
        public int? Attempt { get; set; }
        public double? ZScore { get; set; }
        public string Medium { get; set; }
    }



@model SIMS.Models.StudentIntake.InitialApplicantLevel2Model 
<tr>
        <td>Year: </td>
        <td>@Html.TextBoxFor(o=>o.alResultsModel.Year)</td>
        <td>Index No: </td>
        <td>@Html.TextBoxFor(o=>o.alResultsModel.IndexNo)</td>
        <td>Medium: </td>
        <td>@Html.TextBoxFor(o=>o.alResultsModel.Medium)</td>
    </tr>
    <tr>
        <td>Stream: </td>
        <td>@Html.TextBoxFor(o=>o.alResultsModel.Stream)</td>
        <td>Attempt: </td>
        <td>@Html.TextBoxFor(o=>o.alResultsModel.Attempt)</td>
        <td>Zscore: </td>
        <td>
      @Html.TextBoxFor(o=>o.alResultsModel.ZScore)

        </td>
    </tr>

enter image description here

1 个答案:

答案 0 :(得分:1)

我找到了答案here

  

不幸的是,Kendo UI不支持Class Composition / View Models   包含复杂对象,您的View模型需要完全   避免意外行为。