Grid Complex Model (Create/update model is empty)

1 Answer 12 Views
Grid MultiSelect
Oliver
Top achievements
Rank 1
Oliver asked on 10 Jun 2025, 08:35 AM

Hello,

create/update posts an empty model to the controller.

It was working in a very old asp.net mvc project. I setup a new asp.net core project. I spent some hours to fix this, but no luck.

Reading the data source is ok and the data is shown in column 'valuestream'. At the moment for 'Agenda' two values are shown, editable with a mutiselect.

 

 

Controller:

public ActionResult ManagerQuestionnaireCreate([DataSourceRequest] DataSourceRequest request, QuestionnaireViewModel rs)

....

return Json(new[] { rs }.ToDataSourceResult(request, ModelState));
}

Model:

View:

 

1 Answer, 1 is accepted

Sort by
0
Mihaela
Telerik team
answered on 12 Jun 2025, 01:56 PM

Hello Oliver,

I have tested the case by suign the follwoing MultiSelect editor, and it appears that the Model property "ManagerQnrGroup" is retrieved as expected at my end:

        <div class="k-edit-label">
            @Html.LabelFor(model => model.ManagerQnrGroup)
        </div>
        <div class="k-edit-field">
            @(Html.Kendo().MultiSelectFor(model => model.ManagerQnrGroup)
                .DataValueField("GroupId")
                .DataTextField("GroupName")
                .AutoBind(false)
                .TagMode(MultiSelectTagMode.Multiple)
                .DataSource(source =>
                {
                    source.Read(read =>
                    {
                        read.Action("GetGroups", "Grid");
                    });
                })
            )
            @Html.ValidationMessageFor(model => model.ManagerQnrGroup)
        </div>

    I am attaching a runnable ASP.NET Core sample, where you can test it locally.

    Also, since the data type of the "ManagerQnrGroup" property is IEnumerable<QuestionnaireGroupViewModel>, you can try retrieving its values through a List:

            [AcceptVerbs("Post")]
            public ActionResult Create([DataSourceRequest] DataSourceRequest request, QuestionnaireViewModel rs, List<QuestionnaireGroupViewModel> ManagerQnrGroup)
            {
    
                return Json(new[] { rs }.ToDataSourceResult(request, ModelState));
            }

    Regards,
    Mihaela
    Progress Telerik

    Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

    Oliver
    Top achievements
    Rank 1
    commented on 12 Jun 2025, 04:08 PM | edited

    Hello Mihaela,

    thank you very much for your help and the sample.

    After taking a look at the sample , I've changed the IEnumerable to List and it works without problems.



    Regards & have a nice day, Oliver

     


    Tags
    Grid MultiSelect
    Asked by
    Oliver
    Top achievements
    Rank 1
    Answers by
    Mihaela
    Telerik team
    Share this question
    or