This question is locked. New answers and comments are not allowed.
Hi, I am trying to figure out to add items and sub-items dynamically to a tabstrip at runtime and simply cannot figure out how to do it. Here is what I have so far
This works great as it is but wjhat I need to do is to be able to add items dynamically based upon the model, such as using a foreach loop, something like this maybe?
Which obviously does not work. Can this be done?
@{ Html.Telerik().PanelBar() .Name("PanelBar") .ExpandMode(PanelBarExpandMode.Single) .HtmlAttributes(new { style = "width: 100%;" }) .Items(panelbar => { panelbar.Add().Text("Milestones") .SpriteCssClasses("milestone") .Items(parent => parent.Add().Text("Manage") .SpriteCssClasses("smlOption") .HtmlAttributes(new {data_url = Url.Action("Index", "Milestone")})).Expanded(false); panelbar.Add().Text("Workflow Stages") .SpriteCssClasses("stages") .Items(parent => {parent.Add().Text("Grid") .SpriteCssClasses("icon-ajax-grid"); parent.Add().Text("Editor") .SpriteCssClasses("icon-ajax-editor"); }).Expanded(false); panelbar.Add().Text("Enumerations") .SpriteCssClasses("movie") .Items(parent => { parent.Add().Text("Grid") .SpriteCssClasses("icon-ajax-grid"); parent.Add().Text("Editor") .SpriteCssClasses("icon-ajax-editor"); }).Expanded(false); panelbar.Add().Text("Url") .SpriteCssClasses("urlIcon") .Items(parent => { parent.Add().Text("Grid") .SpriteCssClasses("icon-ajax-grid"); parent.Add().Text("Editor") .SpriteCssClasses("icon-ajax-editor"); }).Expanded(false); }) .ClientEvents(events => events.OnSelect("Select")) .Render();}This works great as it is but wjhat I need to do is to be able to add items dynamically based upon the model, such as using a foreach loop, something like this maybe?
@{ Html.Telerik().PanelBar() .Name("PanelBar") .ExpandMode(PanelBarExpandMode.Single) .HtmlAttributes(new { style = "width: 100%;" }) .Items(panelbar => { panelbar.Add().Text("Milestones") .SpriteCssClasses("milestone") .Items(parent => parent.Add().Text("Manage") .SpriteCssClasses("smlOption") .HtmlAttributes(new {data_url = Url.Action("Index", "Milestone")})).Expanded(false) .Items( @foreach (var i in Model) { parent => parent.Add().Text(i.TreatmentShortName) } )Which obviously does not work. Can this be done?