Base solution for your next web application
Starts in:
01 DAYS
01 HRS
01 MIN
01 SEC
Open Closed

How to add custom attribute in left menu? #901


User avatar
0
tonid created

Hi,

I have this one in AppNavigationProvider:

).AddItem(new MenuItemDefinition(
                    PageNames.App.Tenant.Test,
                    L("Test"),
                    url: "test.dashboard",
                    icon: "icon-notebook"
                    )

And it generates this code:

<a ui-sref="test.dashboard" ng-if="!menuItem.items.length" class="ng-scope" href="#/test/dashboard">
                <i class="icon-notebook"></i>
                <span class="title ng-binding">Test</span>
            </a>

I want to add id attribute to <a> tag, like this:

<a ui-sref="test.dashboard" ng-if="!menuItem.items.length" class="ng-scope" href="#/test/dashboard" id="testId">
                <i class="icon-notebook"></i>
                <span class="title ng-binding">Test</span>
            </a>

I have tried it with customData in MenuItemDefinition, but I didn't get any result. So, how to achieve that?


5 Answer(s)
  • User Avatar
    0
    hikalkan created
    Support Team

    CustomData should work. How did you implemented it? Can you share your server and client side code.

  • User Avatar
    0
    tonid created

    Here my implementation code:

    In AppNavigationProvider.cs

    ).AddItem(new MenuItemDefinition(
                        PageNames.App.Tenant.Test,
                        L("Test"),
                        url: "test.dashboard",
                        icon: "icon-notebook",
                        customData: new System.Collections.Generic.Dictionary<string, string>() {{ "id", "testId" }}
                        )
    

    When I looked at source page:

    <a ui-sref="test.dashboard" ng-if="!menuItem.items.length" class="ng-scope" href="#/test/dashboard">
                    <i class="icon-notebook"></i>
                    <span class="title ng-binding">Test</span>
                </a>
    

    There is no ID attribute.

  • User Avatar
    0
    tonid created

    Hi, any update on this issue?

  • User Avatar
    0
    paulbackhouse created

    I have the same problem. I update the navigation provider I have, have added order and custom data values - these do not get passed through via the Javascript API auto generated scripts.

    I can find out why not, it seems very straight forward but for some reason the serialisation is not passing through order or custom data!

    why?

  • User Avatar
    0
    hikalkan created
    Support Team

    customData not automatically added as HTML attributes. You should also change the menu creation .cshtml file on the template (<a class="postlink" href="https://github.com/aspnetboilerplate/aspnetboilerplate-templates/blob/master/src/AbpCompanyName.AbpProjectName.WebSpaAngular/App/Main/views/layout/header.cshtml#L14">https://github.com/aspnetboilerplate/as ... cshtml#L14</a>) to read custom property and set HTML attributes like ID.