jQWidgets Forums

jQuery UI Widgets Forums TreeGrid Getting all children rows

Tagged: 

This topic contains 4 replies, has 2 voices, and was last updated by  Marc 11 years, 1 month ago.

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
  • Getting all children rows #53789

    Marc
    Participant

    Hi,

    I’d like to get all children of a given row.

    I was – wrongly – believing that ‘getRows’ would return all rows, not only level 1, so I was expecting this code to work :

    var selection = $("#treeGrid").jqxTreeGrid('getSelection');
    var rowid = selection[0].MyRecordID
    var allRows = $("#treeGrid").jqxTreeGrid('getRows');
    var childrenRows = allRows.filter(filterFunction);
    function filterFunction(element, index, array) 
    {
      return (element.ParentID == rowid);
    };

    As you guessed, MyRecordID is the primary key of the record, ParentID its parent (foreign key) field

    .filter being a javascript array method.

    I obviously could not test it, since getRows returns only level 1 records. See a question about it in another post of mine.

    Anyway, are there easy ways to get all children rows of a given parent ?

    Thank you.

    Getting all children rows #53792

    Peter Stoev
    Keymaster

    Duplicate Post: http://www.jqwidgets.com/community/topic/how-to-get-all-rows-in-treegrid/#post-53791

    Please, avoid duplicate posts in the future.

    Getting all children rows #53796

    Marc
    Participant

    Hi Peter,

    Thank you for your replies.

    But now, isn’t *your* statement being incorrect 🙂 ?

    My first question was to get *all* rows…

    This one is to get *children* rows of a given row.

    The next one is get a given row depending on criteria.

    I’m intentionnally splitting the questions, so that it helps other readers to find the very answer they’re looking for…

    Thanks for your help, and let me know if I’m missing something.

    Best regards.

    Getting all children rows #53804

    Peter Stoev
    Keymaster

    “I was – wrongly – believing that ‘getRows’ would return all rows, not only level 1, so I was expecting this code to work :”

    Sorry, but this is the same. You can find my answer in the other topic.

    Best Regards,
    Peter Stoev

    jQWidgets Team
    http://www.jqwidgets.com

    Getting all children rows #53819

    Marc
    Participant

    Hi Pete,

    I see, you seem to have been confused by this sentence. This was not the question, just context info. I was not expecting an answer on this one. The question was in the last line, as well as in the post title.

    I’ll try to be clearer in my next posts.

    Cheers.

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

You must be logged in to reply to this topic.