Here's a rough overview.
- I have a main page, call it MyView.cshtml. It has a Model of MyViewModel; and MyViewModel contains three Person objects, PersonA, PersonB, and PersonC.
- In MyView.cshtml is a TabStrip with three tabs, A, B, and C. These are populated using Html.EditorFor(Model.PersonA), Html.EditorFor(Model.PersonB), and Html.EditorFor(Model.PersonC).
- I have an editor template, Person.cshtml; and in this template (among other items for editing a Person) is a Copy To menu. This is supposed to (eventually) let us copy A to B or C, B to A or C, and C to A or B. Contents of PersonA, etc., are correctly shown in the different tabs, so I know that the views are correctly tied to the different Person objects.
- I have a property CopyTargets in Person that populates a hierarchy of MenuItem. At the top is an item, text = "Copy To". Under that are the items that represent valid targets for this Person.
Here's the snippet that defines the menu:
@{Html.Telerik().Menu()
.Name("copyToMenu")
.BindTo(Model.CopyTargets).Render();
}
Here's the code for CopyTargets:
public List<MenuItem> CopyTargets
{
get
{
List<MenuItem> items = new List<MenuItem>();
MenuItem root = new MenuItem { Text = "Copy To" };
items.Add(root);
foreach (string name in GetCopyTargets())
{
MenuItem target = new MenuItem { Text = name };
root.Items.Add(target);
}
return items;
}
}
(GetCopyTargets is the method that gets the list of targets for each Person.)
When I run this, the Copy To menu appears in Tab A, Tab B, and Tab C; but the menu items only appear in Tab A. I have put a breakpoint in CopyTargets and verified that it gets called three times and that it adds two child items to each one.
Any suggestions of how to make the menu items appear on all three tabs?
Thanks!
Martin