Nov 15, 2013, 3:38 AM
[CLOSED] Issues getting MultiComboFor in MVC Razor to bind
I was looking at this post:
http://forums.ext.net/showthread.php...r-in-MVC-Razor
and this link:
http://mvc.ext.net/#/Models/Model_Bind/
But I have not been able to get the MultiComboFor to show the values that are in the model.
View:
How would I get the MultiComboFor to bind correctly? Or, better yet, how would I select the values in the combo from the server?
Thanks,
Amit
http://forums.ext.net/showthread.php...r-in-MVC-Razor
and this link:
http://mvc.ext.net/#/Models/Model_Bind/
But I have not been able to get the MultiComboFor to show the values that are in the model.
View:
Html.X().MultiComboFor(m => m.EXTSecondaryActivities, false)
.Icon(Model.IsLocked ? Icon.Lock : Icon.None)
.ReadOnly(Model.IsLocked)
.FieldLabel("Secondary Activity")
.ValueField("ASID")
.DisplayField("Description")
.Store(Html.X().Store()
.Model(Html.X().Model()
.Fields(
new ModelField("ASID"),
new ModelField("Description")
).IDProperty("ASID")
)
.DataSource(Model.Activities)),
Model:public IEnumerable<ListItem> EXTSecondaryActivities {
get
{
return (from x in SecondaryActivities
select new ListItem()
{
Value = x.ToString()
});
}
set
{
SecondaryActivities = (from x in value select Convert.ToInt32(x.Value)).ToArray();
}
}
Controller:var result = new Ext.Net.MVC.PartialViewResult()
{
ViewName = "EditStudent",
ContainerId = containerId,
WrapByScriptTag = false,
Model = estudent,
RenderMode = Ext.Net.RenderMode.Replace,
IDMode = IDMode.Static,
ControlId = containerId
};
The model is inheriting from another class that has the multiple values in an int array. I have the EXTSecondaryActivities returning an IEnumerable<ListItem> as in the example. I would prefer to just use the int array so I would not have to inherit the base class (I could just use it directly).How would I get the MultiComboFor to bind correctly? Or, better yet, how would I select the values in the combo from the server?
Thanks,
Amit
Last edited by Daniil; Nov 22, 2013 at 4:08 AM.
Reason: [CLOSED]