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
335
Parent Rows in a hierachical Grid
posted

Hello everyone, i got a problem with my ultragrid:

I have a dataset with datarelations bound to my ultragrid. It is possibly that entity A has a relation to C, and B has also a relation to C. So C can have different parents from different bands. In the Grid that means that C is shown multiple times (under A and also under B).

I have in every row a checkbox column. If I check it, all parent rows need to get checked too. There exists row.ParentRow, which returns the parent row under which I checked C. But that gives me only one row, but I need not only A or B, I need A and B. I realize that there is also row.ParentCollection, but if I understood correctly, that gives me only each row of the band C belongs to.

Is there a possibilty to get A and B?

 

Parents
  • 469350
    Verified Answer
    Offline posted

    As far as the grid (and the relationship) are concerned, the C object under row A and the C object under row B are two different instances and there is no relationship between them. So there's no way the grid can handle this for you.

    The only way to do this would be for you to detect this case. I imagine that would involve watching for the checkbox on row C (either one), and then looping through all of the row in the parent band (which contains both items A and B) and then examining the child rows of every item in that collection to see if there is an item C under it. This would, of course, be very inefficient.

    Another approach you could take to make this more efficient would be to create some other data structure that tracks all of these links. So you could loop through all of the rows in the grid up-front and then build some sort of mapping structure. That way, when someone checks item C, you don't have to loop again, you just have to consult your mappings and find any related objects. But the down side of this approach is that you have to update your mapping structure any time the data changes.

Reply Children