This is a migrated thread and some comments may be shown as answers.

[Solved] Menu showing only 2 levels of items

4 Answers 76 Views
Menu
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Reid
Top achievements
Rank 2
Reid asked on 01 Jan 2012, 04:28 PM
Hello,


I am working on my first Telerik MVC menu and have it working for the most part except that only the first level of child menu items are being processed.  The top level items load and when dropped down contain the second level items.  That is where it ends and looking at this code I am not sure how to fix this.

The menu part of this app was adapted from a previous post (can't find the link) with a Telerik representative posting an attachment.  The demo uses a MenuIndexModel, MenuModel, and MenuItem model scenario. The menu loads from the database and has integrity in the relational data keys in that the table is recursive with every menu item having a parent key.  The exception being the parent items where the ParentMenuItemPK value is null, which defines the top most items. The schema also has the Controller name and action columns.

Without posting code, does anyone have a example they could share that will recursively build what the Menu needs as the model and create every nested child menu item?

4 Answers, 1 is accepted

Sort by
0
Accepted
Georgi Tunev
Telerik team
answered on 03 Jan 2012, 12:45 PM
Hello Reid,

 I believe that the Binding to Model demo will be of help.


All the best,
Georgi Tunev
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the Telerik Extensions for ASP.MET MVC, subscribe to their blog feed now
0
Reid
Top achievements
Rank 2
answered on 03 Jan 2012, 01:28 PM
Hello Georgi,

Thanks for replying.  I will take a look at this again, it does not demonstate a deeper level of nesting.  My app is doing this as well.  It fails when the children of any menu item has children as well. 

Thanks,

Reid
0
Georgi Tunev
Telerik team
answered on 03 Jan 2012, 03:01 PM
Hi again Reid,

Here is a modified version of the code that shows how to do this - I hope this helps. You can see the result in the attached screenshot.
<%= Html.Telerik().Menu()
        .Name("Menu")
        .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;
                    })
                    .Children(product => product.Order_Details));
 
            mappings.For<Order_Detail>(binding => binding
                    .ItemDataBound((item, order_detail) =>
                    {
                        item.Text = order_detail.UnitPrice.ToString();
 
                    }));
                     
        })
%>




Greetings,
Georgi Tunev
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the Telerik Extensions for ASP.MET MVC, subscribe to their blog feed now
0
Reid
Top achievements
Rank 2
answered on 03 Jan 2012, 05:27 PM
Greeting again Georgi,

I really appreciate you doing this.  I will adapt my project to your code here!

Thanks!


Reid
Tags
Menu
Asked by
Reid
Top achievements
Rank 2
Answers by
Georgi Tunev
Telerik team
Reid
Top achievements
Rank 2
Share this question
or