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

[Solved] Question about Menu

1 Answer 107 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Maria
Top achievements
Rank 1
Maria asked on 06 Dec 2010, 08:07 PM
Hi All,
I am interested in buying Telerik, and I have some doubts working with Menus. I have a table with the opcion to create a Menu, some rows are primay opcion and other are subopcion. The code I'm using to create the menu is as followed, but instead of create the menu with subitem, just create opcion. Any ideas about what I'm doing wrong ??.
Also working with MVC 3 can I use Htm.RenderAction() in the Site.Master page????

Thanking any help....

Maria

<% if (Model != null) 
    Html.Telerik().Menu() 
        .Name("Menu") 
        .Items(items => 
        {
            var nivel0 = Model.Where(n => n.Nivel == 0).ToList<ModeloDatos.PruebaMenu>();
             
            for (int i = 0; i < nivel0.Count; i++)
            {
                // guardo el valor del padre
                int IdPadre = nivel0[i].MenuId;
                string texto = nivel0[i].Texto;
                // aƱado el item
                items.Add()
                    .Text(nivel0[i].Texto)
                    .Items(subitem =>
                        {
                              
                            var nivel1 = Model.Where(s => s.PadreId == IdPadre).ToList<ModeloDatos.PruebaMenu>();
                              
                            for (int j = 0; j < nivel1.Count(); j++)
                            {
                                items.Add()
                                    .Text(nivel1[j].Texto);
                            }
                              
                         }); 
            }
  
        }) 
        .Render(); 
%>

1 Answer, 1 is accepted

Sort by
0
Atanas Korchev
Telerik team
answered on 07 Dec 2010, 08:43 AM
Hello Maria,

 You are adding all items to the first level:

for (int j = 0; j < nivel1.Count(); j++)
                            {
                                items.Add()
                                    .Text(nivel1[j].Texto);
                            }

Try changing it to this:
for (int j = 0; j < nivel1.Count(); j++)
                            {
                                subitem.Add()
                                    .Text(nivel1[j].Texto);
                            }

Regards,
Atanas Korchev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
General Discussions
Asked by
Maria
Top achievements
Rank 1
Answers by
Atanas Korchev
Telerik team
Share this question
or