Context Menu in Radzen Tree

Hi Radzen Team,

i need to add Conext Menu for self referenced Tree.
In one of your posts you suggested to add below code for that:

  <RadzenTreeItem>
      <Template>
          <b @oncontextmenu=@(args=> ShowContextMenu(args)) @oncontextmenu:preventDefault="true">@context.Text</b>
      </Template>
  </RadzenTreeItem>

I have added it as below. But still it is not showing context Menu. (Note: I have to use RadzenTreeLevel)

Could you please help me here?

Thanks in advance,
Heena

Works normally in our demos:


Make sure you have RadzenComponents or RadzenContextMenu as per our Getting started in your main layout.

I think the problem is that your RadzenTree is data-bound. You need to set the template per level:

<RadzenTreeLevel @* other options here *@ >
    <Template>
          <b @oncontextmenu=@(args=> ShowContextMenu(args)) @oncontextmenu:preventDefault="true">@context.Text</b>
    </Template>
</RadzenTreeLevel>
1 Like

This solution works. Thanks