Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
20
How to set a link url or controller action in a tree childnode
posted

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",
                      }

           });

      });
});

Parents
  • 600
    Verified Answer
    Offline posted

    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

Reply Children