chamara
chamara

Reputation: 12709

Kendo Grid edit popup complex model submitting

I’m trying to use complex models with Kendo grid edit popup. When submitting ALResults object properties are always null. It works fine when I’m not using Kendo. Is there a problem with kendo complex model submitting?

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

Upvotes: 0

Views: 638

Answers (1)

chamara
chamara

Reputation: 12709

I found the answer here

Unfortunately Kendo UI doesn't support Class Composition / View Models containing complex objects, your View Models need to be completely flat to avoid unexpected behaviour.

Upvotes: 1

Related Questions