Multi select returns an array with the correct count, but the values are null?

4 posts, 0 answers
  1. Elliott
    Elliott avatar
    2 posts
    Member since:
    Nov 2013

    Posted 04 Dec 2013 Link to this post

    Hi, I'm having a bit of trouble getting a multi select to pass the values back to the controller.
    Here's what I have currently tried:

    In my model:
    [UIHint("abcEditor")] <- name of partial view containing the multiselect (used on grid popup window)
     public string[] abc { get; set; }

    In my partial view:
    @using Kendo.Mvc.UI
    @(Html.Kendo().MultiSelect()
        .Name("abc") // Name of the widget matches in the model
        .DataValueField("ID")  <- PersonModel (Contains - ID, FullName, Email, etc..)
        .DataTextField("FullName")  
        .BindTo((System.Collections.IEnumerable)ViewData["def"]) // A list of PersonModels which is populated in the controller
        .Placeholder("Add")  
    )

    Controller: (Received Values)
    - model.abc     {string[2]} string[]
        [0] null string
        [1] null string

    ID is a Guid but if I try Guid[] I get the same result. 
    I can select things fine, and it returns an array with the correct number selected, but the values in the array are null?
    If anyone can point me in the right direction it would be a great help!
    Thanks
  2. Petur Subev
    Admin
    Petur Subev avatar
    1882 posts

    Posted 04 Dec 2013 Link to this post

    Hello Elliott,

    In the latest version (Q3 2013) we changed the grid/dataSource to successfully serielize and send the values of nested Array properties to the server, can you confirm that you are using the latest version of Kendo? Also the following code library demonstrates how to use the MultiSelect in grid within this code library (for versions prior the one mentioned above).

    If still struggling please demonstrate the problem that you have with a small demo project so we can investigate further.

    Kind Regards,
    Petur Subev
    Telerik
    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
  4. Susan
    Susan  avatar
    1 posts
    Member since:
    Feb 2014

    Posted 19 Apr 2014 in reply to Petur Subev Link to this post

    I have tried to change the inline editing to popup and example became broken. Do we have a way to use MultiSelect like in the example above but with PopUp edit mode?

    Thank you!
  5. Petur Subev
    Admin
    Petur Subev avatar
    1882 posts

    Posted 22 Apr 2014 Link to this post

    Hello Susan,

    The error that you might see is the that inside EditorTemplates/String.cshtml you will have to change the model from string to object

    e.g.

    @model object
     
    @Html.TextBoxFor(model => model, new {@class="k-textbox" })

    Once the project runs again, you will see that in the popup the MultiSelect editor is not applied, this is because Html.EditorForModel method that the Grid uses internally does not generate editors for the nested complex properties. 

    To make it work you will have the customize the whole popup editor like described here, and re-use the MultiSelect configuration from the TerritoriesEditor.cshtml.

    If you faced an issue during the implementation share your project here so I can advise you further.

    Kind Regards,
    Petur Subev
    Telerik
     
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
     
Back to Top
Kendo UI is VS 2017 Ready