This is a migrated thread and some comments may be shown as answers.

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

3 Answers 221 Views
MultiSelect
This is a migrated thread and some comments may be shown as answers.
Elliott
Top achievements
Rank 1
Elliott asked on 04 Dec 2013, 09:43 AM
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

3 Answers, 1 is accepted

Sort by
0
Petur Subev
Telerik team
answered on 04 Dec 2013, 11:35 AM
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!
0
Susan
Top achievements
Rank 1
answered on 19 Apr 2014, 02:28 PM
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!
0
Petur Subev
Telerik team
answered on 22 Apr 2014, 01:00 PM
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!
 
Tags
MultiSelect
Asked by
Elliott
Top achievements
Rank 1
Answers by
Petur Subev
Telerik team
Susan
Top achievements
Rank 1
Share this question
or