3 Answers, 1 is accepted
0
Hello Jim,
To achieve your goal you will need to use ToComponent() method, which will return the PanelBar object.
Thus you will be able to sort them, before render.
Here is an example how to use it in the view:
Greetings,
Georgi Krustev
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
To achieve your goal you will need to use ToComponent() method, which will return the PanelBar object.
Thus you will be able to sort them, before render.
Here is an example how to use it in the view:
<% var builder = Html.Telerik().PanelBar() .Name("PanelBar1") .BindTo("SiteMap"); var panelBar = builder.ToComponent(); panelBar.Items.OrderBy(item => item.Text); builder.Render();%>Greetings,
Georgi Krustev
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Jim
Top achievements
Rank 1
answered on 19 Jan 2010, 04:02 PM
Thank you,
I understand that this will sort the PanelBar items, but I wish to sort the subItems within an individual panel.
Thanks,
Jim
I understand that this will sort the PanelBar items, but I wish to sort the subItems within an individual panel.
Thanks,
Jim
0
Hi Jim,
You can use the following approach to sort all items:
Sincerely yours,
Atanas Korchev
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
You can use the following approach to sort all items:
<script runat="server"> public void SortItems(INavigationItemContainer<PanelBarItem> owner) { IList<PanelBarItem> sortedItems = owner.Items.OrderBy(item => item.Text).ToList(); owner.Items.Clear(); foreach (PanelBarItem item in sortedItems) { SortItems(item); owner.Items.Add(item); } } </script><%var panelbar = Html.Telerik().PanelBar() .Name("PanelBar") .HtmlAttributes(new { style = "width: 300px;" }) .BindTo(Model, mappings => { mappings.For<Category>(binding => binding .ItemDataBound((item, category) => { item.Text = category.CategoryName; }) .Children(category => category.Products)); mappings.For<Product>(binding => binding .ItemDataBound((item, product) => { item.Text = product.ProductName; })); }).ToComponent(); SortItems(panelbar); panelbar.Render();%>Sincerely yours,
Atanas Korchev
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.