I have a bunch of items that I have grouped up by Header.
I would like to display them on the page with the header text followed by the editor template for each individual item.
I tried using nested templates as follows:
Main Page:
@Html.EditorFor(x => x.GroupedItems, "ListofGrouping");
ListofGrouping Editor Template:
@model IList<IGrouping<string, Model>>
@for(int i = 0; i < Model.Count(); i++)
{
@Html.EditorFor(x => x[i],"IGrouping")
}
IGrouping Editor Template:
@model IGrouping<string, Model>
@Html.DisplayFor(x => x.Key)
@Html.EditorForModel()
This works up till the last line. I get all the header values but the individual items are not displayed.
If I can't get it to work this way I will just use a data grid and do the grouping there, but I figured this should be possible in MVC3.