Skip to content

Infragistics Community Forum / Web / Ignite UI for ASP.NET MVC / How to set a link url or controller action in a tree childnode

How to set a link url or controller action in a tree childnode

New Discussion
Eduardo Mayorgas
Eduardo Mayorgas asked on Mar 23, 2025 6:02 AM

Hi, I´m in a mvc .net project and I have no idea how to set the <a href> property tag in the <li> with the Json function, how can I change the ‘#’ in the href and the target?

My Cshtml have the tree menu like this elements:

<ul style=”” data-depth=”2″>

<li class=”ui-igtree-node ui-igtree-node-nochildren” data-path=”0_2_0″ data-value=”000000000000000000000000″ data-role=”node”>

<a href=”#” target=”_self” class=”ui-corner-all”>Lorem Ipsum dolor sit amet</a>

</li>

</ul>

I load the tree menu with a Json like this structure:

My Json is like:

$(function () {

var data = [];
$.post(“LoadMenuTree”, {}, function (menu, status) {
data = menu;

// Initialize igTree
$(“#tree”).igTree({
dataSourceType: “json”,
dataSource: data,
initialExpandDepth: 0,
bindings: {
textKey: “menu_string”,
valueKey: “id”,
childDataProperty: “menuDto”,
}

           });

      });
});

Sign In to post a reply

Replies

  • 0
    Riva Ivanova
    Riva Ivanova answered on Nov 24, 2022 7:02 AM

    Hello Eduardo,

    Thank you for posting into our community!

    I have been looking into your question and what I could suggest in order to change the target attribute is setting the defaultNodeTarget option of the igTree. This option will set the default target attribute value for all node anchors. However, if you require the target attribute to be different for some nodes, what I could suggest is using the targetKey option.

    Additionally, setting custom values for the href attribute could be achieved by using the navigateUrlKey option.

    Here could be found a small sample demonstrating my suggestion. Please test it on your side and let me know if you need any further assistance regarding this matter.

    Looking forward to your reply.

    Sincerely,
    Riva Ivanova
    Entry Level Software Developer

    • 0
      Eduardo Mayorgas
      Eduardo Mayorgas answered on Nov 24, 2022 9:01 AM

      Thnaks a lot, I´d resolve my issue with your tip 😉

      • 0
        Riva Ivanova
        Riva Ivanova answered on Nov 24, 2022 9:06 AM

        Hello Eduardo,

        I am glad that you find my suggestion helpful.

        Thank you for using Infragistics components.

        Regards,
        Riva Ivanova
        Entry Level Software Developer

    • 0
      Hayley Riley
      Hayley Riley answered on Dec 13, 2023 7:57 AM

      Thank you for answering, you made my day. My issue was also resolved all because of you. I appreciate you mam.

    • 0
      Vimusic apk
      Vimusic apk answered on Dec 31, 2024 11:23 AM

      To set a link URL or controller action in a tree child node:

      1. JavaScript Framework: Use frameworks like jQuery or Vue.js to dynamically assign URLs to nodes.

      2. HTML Structure: For static trees, use <a> tags within child nodes:

        <li><a href="/controller/action">Child Node</a></li>
        
      3. Dynamic Rendering: In backend frameworks (e.g., ASP.NET, Django), generate tree nodes with URLs/actions during rendering.

      4. Event Listeners: Attach click events programmatically to nodes to redirect to the desired URL.

  • 0
    Raja Singh
    Raja Singh answered on Mar 23, 2025 6:02 AM

    I try first, then let you know..

  • You must be logged in to reply to this topic.
Discussion created by
Favorites
Replies
Created On
Last Post
Discussion created by
Eduardo Mayorgas
Favorites
0
Replies
6
Created On
Mar 23, 2025
Last Post
11 months, 1 week ago

Suggested Discussions

Created by

Created on

Mar 23, 2025 6:02 AM

Last activity on

Feb 24, 2026 1:05 PM