jQWidgets Forums

jQuery UI Widgets Forums Getting Started JQTree Widget GetChildren, GetAllChildren Enhancement

This topic contains 5 replies, has 3 voices, and was last updated by  Dmitry Istomin 11 years, 3 months ago.

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

  • Andy
    Participant

    I am very new to this list so forgive me if I am repeating an already asked question or request, but it appears to me that the above Methods would be a great enhancement to the Tree Widget.

    Cheers,

    Andy


    Peter Stoev
    Keymaster

    Hi Andy,

    The “getItems” method returns all Items loaded into jqxTree. You may learn more about it from the jqxTree’s API docs.

    Best Regards,
    Peter Stoev

    jQWidgets Team
    http://www.jqwidgets.com


    Dmitry Istomin
    Participant

    +1 to Andy. If I am correct, you have to go through all the list of items to select children for a particular element. It would be great to have an opportunity of doing this without any iterations.


    Peter Stoev
    Keymaster

    Hi Dmitry,

    You can select only one item at a time. “getItems” returns all items. There’s is also a method – selectItem which allows you to select a specific item without iterating anything.

    Best Regards,
    Peter Stoev

    jQWidgets Team
    http://www.jqwidgets.com


    Dmitry Istomin
    Participant

    Hi, Peter!

    Sorry, I probably mislead you. By select I meant get – get objects of items dynamically at runtime. I will try to explain myself to be more clear.

    Result of getItems does not have any hierarchy. To get all root items I need to go through each item and check whether a parentElement property is null.

    To get children of a particular item that is retrieved by getItem I need to call getItem again using subtreeElement property and then read nextItem property of each subsequent item until it is null.

    So in each case we have to iterate through each item in a result to get a list of item’s children. I think it would be much better if you have items property in each item object or have getChildren method.

    Please correct me if I am wrong.

    Thank you!


    Dmitry Istomin
    Participant

    Sorry, I realized that I was wrong about subtreeElement. It is a container for item elements and not a first child as I thought before. Here is a code which gets children for a particular element:

    $(parentElement.subtreeElement).children(‘li’).each(function (i, c) {
    item = e.jqxTree(‘getItem’, c);
    //Some code which uses item object
    })

    But anyway, it would be great to have a function getChildren(parent) which returns sub-items as objects. And if you provide no parent (or provide null) then it returns you all root items (e.g. those which do not have a parent).

    Thanks!

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

You must be logged in to reply to this topic.