jQuery UI Widgets Forums Navigation Tree How to get all child nodes by it’s parent

This topic contains 8 replies, has 3 voices, and was last updated by  Dimitar 10 years, 10 months ago.

Viewing 9 posts - 1 through 9 (of 9 total)
  • Author

  • yehezqiel
    Member

    Hi, it’s the first time for me using jqxTree.. It was so great.

    I want to ask some questions. I have a tree like this :

    Root

    —–Child 1

    ————- Data a

    ————- Data b

    ————- Data c

    —–Child 2

    ————- Data d

    ————- Data e

    ————- Data f

    —–Child 3

    ————- Data g

    1. How to get all child nodes by it’s parent. For example when I check child 2, then it return Data d, data e, and data f ?

    2. Is it possible to disable node select in a tree ? I mean, when I double click on a node, the tree was expand.. how to disable double click in a node, so it wouldn’t expand node ?

    thx before..


    Dimitar
    Participant

    Hello yehezqiel,

    Here is how to get the descendants of a selected node:

                $('#jqxTree').on('select', function (event) {
    var e = event.args.element;
    var children = $(e).find("li");
    });

    There is now way of disabling a particular node select, except for the disableItem method.

    Best Regards,
    Dimitar

    jQWidgets team
    http://www.jqwidgets.com/


    yehezqiel
    Member

    Thank’s Dimitar.. it works..

    Can I ask again ? 😀

    In Api Reference, Initialize events was : “The initialized event is triggered when the jqxTree is created and initialized.”

    I put an alert method in initalized code, but when the tree was appear in browser, there is no alert appear.. Is initialize is an event that was first run ?

    thx before..


    Dimitar
    Participant

    Hi yehezqiel,

    The initialized event code should be put before the initialization of the tree itself.

    Best Regards,
    Dimitar

    jQWidgets team
    http://www.jqwidgets.com/


    yehezqiel
    Member

    Thank you so much Dimitar… GBU


    yehezqiel
    Member

    I have a questions again.. could you help me again, please :D. Should I create a new topic or post in here ?

    I have a checkboxtree. When I check some item, or expand some node and then I submit the form into server. I want to display the same tree as before I submit the form.

    I’m using JSP+Java, so in server i create a string with checked:true, expanded: true.. The tree was successfully checked, but not with expanded.. it was expand, but there is no ajax load.. just show “Loading”..

    Could you show me to expand some node after the jqxTree is created and initialized.

    thx…


    yehezqiel
    Member

    Solved… I’m using $(window).load() to expand choosen node after tree has been created


    breetty
    Participant

    Hi yehezqiel

    Can u tell me how to get the children nodes from parent?

    I used the same code here, but it is returning as objects and I am not able to get the values from it.

    Tx in advance…

    Breetty


    Dimitar
    Participant

    Hello Breetty,

    The proposed approach is suitable for getting the the HTML elements of the node’s children. Here is how to modify the code to alert the labels of these children. Note that it works correctly only if they do not have children of their own.

    $('#jqxTree').on('select', function (event) {
        var e = event.args.element;
        var children = $(e).find("li");
        var childrenLabels = new Array();
        for (var i = 0; i < children.length; i++) {
            childrenLabels.push(children[i].innerText);
        };
        alert(childrenLabels);
    });

    Best Regards,
    Dimitar

    jQWidgets team
    http://www.jqwidgets.com/

Viewing 9 posts - 1 through 9 (of 9 total)

You must be logged in to reply to this topic.