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?
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.
Hi Mike, thank you for your information!
I solved the problem now by working on the DataSource (a dataSet) directly and update then the grid after that with ultragrid.updateData(). The challenge was to get the DataRow which belongs to the given UltraGridRow. Is there a easy way to do this?
Renelope said:The challenge was to get the DataRow which belongs to the given UltraGridRow. Is there a easy way to do this?
Yes, just use the ListObject property of the grid row. This will return a DataRowView and you can get the Row property of that.