TwitterBootstrapMvc icon indicating copy to clipboard operation
TwitterBootstrapMvc copied to clipboard

Enhancement: optgroup tag support to ListBoxFor

Open mmunnis opened this issue 11 years ago • 2 comments

Very handy for grouping items in a list box.

mmunnis avatar Jan 14 '14 22:01 mmunnis

Well, regular Html.ListBoxFor does not have support for this tag. I'm fine with extending this functionality, but what do you think syntax should be for this?

DmitryEfimenko avatar Jan 14 '14 22:01 DmitryEfimenko

Maybe something like a Group class.

public class Group<K, T>
{
    public K Key;
    public IEnumerable<T> Values;
}

Then allow the user to pass an IList<Group<K, T>>

Have the helper accept something like this:

@f.FormGroup().ListBoxFor(m => m.MyModelField, Model.MyPassedGroup, mpg => mpg.Values.Id, mpg => mpg.Values.Name).OptLabel(true).LabelValue(mpg => mpg.Key)

That's pretty loose, just thinking out loud.

mmunnis avatar Jan 14 '14 23:01 mmunnis