Details parent() to get the row?

Details parent() to get the row?

Rothrock42Rothrock42 Posts: 7Questions: 3Answers: 0

I'm using Row details to display extra information for each item in my table.

I see from the source row I can use row.child() to get a reference to the details panel (if it exists) for a given row.

Is there a way to go backwards? If I have a reference for the details can I get the parent?

This question has an accepted answers - jump to answer

Answers

  • colincolin Posts: 15,142Questions: 1Answers: 2,586

    Hi @Rothrock42 ,

    I don't believe you can, not if it's just the return from row.child(). If it's the jQuery node, you could use nearest('tr'), but I suspect that's no use for you,

    Cheers,

    Colin

  • allanallan Posts: 61,650Questions: 1Answers: 10,094 Site admin
    Answer ✓

    Yes, there isn't an API to go backwards as such, but you could use $().nearest() as Colin suggests and then $().prev() to select the previous tr which would be the parent row.

    Alternatively, use row().child() looping over each row in the table and checking to see if it has the child row you are looking for. I think that's the approach I'd take.

    Allan

  • Rothrock42Rothrock42 Posts: 7Questions: 3Answers: 0

    Thanks for the suggestions. I think the combination of nearest() and prev() will do it.

This discussion has been closed.