last day (23 days later) » 

10:34 PM
0
Q: Kendo MultiSelect does not populate binded values

Saber AmaniI have a MultiSelect belongs to Kendo ListView EditorTemplates. When I want to submit selected MultiSelect values, I got list of items selected, but all populated with 0 value. I cant get correct value of selected items. Here is my ListView: @(Html.Kendo().ListView<esCMS.Modules.C2C.Domain.c2cF...

 
Have you tried setting the DataTextField/DataValueField settings for the multiselect control?
 
Yes I tried, but nothing changed.
 
What is contained within your ViewBags.Fields collection and the datatype of the items? what are you expecting to be posted back?
 
I updated my post, have a look.
 
What is the data type of the fieldID? Is it a guid/string/int/ other?
 
10:34 PM
It is IEnumerable<int>. I inspected select element of dropdown wrapped by kendo stuffs. Values for options are there. But I get nothing.
Well, I'm here.. thanks for your replies.
 
I am assuming this collection should be getting posted back as part of your viewmodel. do all the other values get posted back.
 
I test it with a simple dropdown. It works fine
 
I had a similar issue with a custom enum not being posted back originally so converted it a key value pair of type <string, int>
have you tested just sending the collection back by itself outside of the main viewmodel
 
Yes.. I tested sending a single value back to server and I got that.
I think there is a problem with collection.
 
but if you are using a multiselect then you are expecting a collection so if you send the collection back as say a list<int> does that work?
 
10:41 PM
No, I tested it with a simple dropdown list. not multiselect
 
ok. let me just check some code for a similar issue I had
 
thank you...
 
ok try also setting the .Value to (new SelectList(Model.SelectedValues,"FieldID", "Title"))
 
ok let me try that
nothing changed... still no value
 
ok try setting the valuePrimitive option to true
 
10:53 PM
ok..
this time selectedvalues collection is null
:( what is wrong with this?? I used multiselect so many times outside editortemplates and all work fine.
I can't figure out what is the problem in here!!
 
yeah it seems to be an issue with the default model binder. Is it possible for you to send me the bits of code that are required for me to test this.
 
its a cms module code.. you can try that by using listview and declare a simple editor template
 
let me check something then
 
its too late here.. im going to sleep. i will check your replies later. thanks for your help David. :) ;)
 
ok. I have a work around that I have used for this problem by creating a type of listitem class. like this; public class BaseFilterModel : IBaseFilter
{
private string itemTemplate = "";

public string Value
{
get;
set;
}

public string Text
{
get;
set;
}

public string ItemTemplate
{
get
{
return (!string.IsNullOrEmpty(itemTemplate))? itemTemplate : Text;

}
set
{
itemTemplate = value;

}

}

}
then bind the multiselect to this something like this:
@(Html.Kendo().MultiSelectFor(m => m.OperatorsAsFilterModel)
.AutoBind(true)
.IgnoreCase(true)
.Filter(FilterType.Contains)
.DataSource(data =>
{
data.ServerFiltering(false);
data.Read("LinqOpRead", "DynamicFilter", new { area = "" });

})
.Placeholder("Select Allowed Operators")
.DataTextField("Text")
.DataValueField("Value")

.Value(new SelectList(Model.OperatorsAsFilterModel, "Value", "Text"))


)
 

  last day (23 days later) »