TwitterBootstrapMvc
TwitterBootstrapMvc copied to clipboard
Enhancement: optgroup tag support to ListBoxFor
Very handy for grouping items in a list box.
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?
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.