Base solution for your next web application
Open Closed

Menu adding a counter #5706


User avatar
0
Garysund created

Hi There

I would like to add a counter on the menu showing how many items there are for a particular menu item.

How would I extend the menu provider to handle this. I am using the MVC Jquery version of asp.net zero

Thanks


4 Answer(s)
  • User Avatar
    0
    ismcagdas created
    Support Team
  • User Avatar
    0
    Garysund created

    I have the _Sidebar.cshtml code

    @if (menuItem.Items.IsNullOrEmpty()) { <a href="@menuItem.CalculateUrl(ApplicationPath)"> <i class="@menuItem.Icon"></i> <span class="title">@menuItem.DisplayName</span> <span class="count">@menuItem.CustomData</span> </a> }

            `.AddItem(new MenuItemDefinition(
                        PageNames.App.Common.Employee,
                        L("Employees"),
                        url: "Mpa/employees",
                        requiredPermissionName: AppPermissions.Pages_Administration_Employees,
                        customData : 4
                        )`
    

    I can add the count on the MpaNavigationProvider.cs and pass through the count as customData. Will the above code work

  • User Avatar
    0
    ismcagdas created
    Support Team

    You don't need that I guess. You can use Model.MenuItem.Items.Count to show the child item count.

    Or you can use a javascript code to create those numbers after the menu is rendered. Because in some cases, menu items might not be displayed for users who doesn't have required permission.

  • User Avatar
    0
    alper created
    Support Team

    No response for 15 days from the owner. closing...