MultiSelect not posting objects correctly

2 posts, 0 answers
  1. Matt
    Matt avatar
    66 posts
    Member since:
    Apr 2012

    Posted 01 May 2013 Link to this post

    I have an object:
    public class User
    {
        public int Id { get; set; }
        public string Name { get; set; }
    }
    And in the editor template, where model.Members are a collection of Users
    @(Html.Kendo().MultiSelectFor(model => model.Members)
        .DataValueField("Id")
        .DataTextField("Name")
        .Placeholder("Type user's name...")
        .DataSource(source =>
        {
            source.Read(read =>
            {
                read.Action("MemberRead", "Group");
            });
        }))
    When posting the form containing this multiselect I get the following post data
    Id:0
    Name:Test
    Description:Test
    Members.Id:1
    Members.Name:Jan
    Members:[object Object]
    Now as far as I can tell the post data is correct, except for"Members:[object Object]" which Kendo throws an error for. When the model is received by the controller, the Members field is null.

    What settings are incorrect?

    (Note that MemberRead is populating the MultiSelect correctly)

    (Also note that this form is part of a popup editor of a grid, in which everything else is working correctly)
  2. Georgi Krustev
    Admin
    Georgi Krustev avatar
    3707 posts

    Posted 05 May 2013 Link to this post

    Hello Matt,

    In general, the MultiSelect widget posts selected values of SELECT element. Depending on the given code snippets I suppose that the widget is used as a editor template in the grid. If this is the case I will suggest you examine this code library.
     

    Greetings,
    Georgi Krustev
    the Telerik team
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
  3. Kendo UI is VS 2017 Ready
Back to Top