This is a migrated thread and some comments may be shown as answers.
parent is rendered when there's no children
3 Answers 25 Views
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Alexandre Jobin
Top achievements
Rank 1
Alexandre Jobin asked on 22 Nov 2011, 04:41 PM
with the v2011.3.1115, the parent node is rendered when there's no children. With the code bellow, Commandes and Transmettre are shown but there's no submenu to show because the user have no Authorization.

Html.Telerik().Menu()
    .Name("Menu")
    .Items(menu =>
    {
        menu.Add()
            .Text("Commandes")
            .Items(items =>
            {
                items.Add()
                    .Action("Index", "Commandes", new { area = "" })
                    .Text("Liste");
 
                items.Add()
                    .Text("Transmettre")
                    .Items(sousItems =>
                    {
                        sousItems.Add()
                            .Action("TransmettreCommandesClient", "Commandes", new { area = "" })
                            .Text("Commande client");
 
                        sousItems.Add()
                            .Action("TransmettreCommandesFournisseur", "Commandes", new { area = "" })
                            .Text("Commande fournisseur");
                    });
            });
    })


i used this code in the pass to define the menu (taken from this forum) but its not working at 100% now. Transmettre is not rendered but Commandes are still there:

.ItemAction(item =>
{
    // Ce code sert à ne pas afficher le menu Parent si tous les enfants ne sont pas accessible
    bool hasAccessible = true;
    foreach (var children in item.Items)
    {
        hasAccessible = false;
        if (children.IsAccessible(navAuthorization, ViewContext))
        {
            hasAccessible = true;
            break;
        }
    }
    item.Visible = hasAccessible;
})

3 Answers, 1 is accepted

Sort by
0
Georgi Krustev
Telerik team
answered on 28 Nov 2011, 09:17 AM
Hello Alexandre,

 
Check this test project, which shows how to hide the parent items, which does not have any children. 

Kind regards,
Georgi Krustev
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
Alexandre Jobin
Top achievements
Rank 1
answered on 30 Nov 2011, 03:44 PM
hi Georgi!

i have updated your demo to show you the problem. You will see that the menu 'Commandes' is shown when there's no item under it. The menu is composed that way:

- Commandes
     - AuthorizedUser
     - AuthorizedAdmin
     - Create
           - AuthorizedUser
           - AuthorizedAdmin
0
Georgi Krustev
Telerik team
answered on 05 Dec 2011, 03:10 PM
Hello Alexandre,

 
In order to achieve the required behavior I have re-implement the logic, which hides the items. Now it seams to work correctly. Check the attached archive and let me know if I am missing something.

Regards,
Georgi Krustev
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
Tags
Menu
Asked by
Alexandre Jobin
Top achievements
Rank 1
Answers by
Georgi Krustev
Telerik team
Alexandre Jobin
Top achievements
Rank 1
Share this question
or