I have a grid with 3 bands bound to a UltraDataSource object.
Band 0 shows department data. Band 1 shows employee data and every row has always one child row in band 2. Users can expand/collapse band 1 to show / hide the data in band 2.
My problem is that users can add additional rows for each employee in band 1. Now in band 1 are row 0 and row 1 for the first employee, row 2 and row 3 for the second and so on.
The additional data in band 2 should always be shown after the last row of each employee in band 1. Therefore I have to move the childrow in band 2 from one parent to another parent.
What is the best way to achieve this?
I'm was looking for a way to remove the whole row and attach it to the other parent. If I could do this, I don't need to setup data, row hight, appearance again for all rows in band 2. But I could not find a way to do this. Should I operate on the data source or on the grid?
Thanks for your help.
Markus
Hi Markus,
I'm having trouble following you. I understand you have three bands (Band 0, 1, and 2). And that every row in band 1 has exactly 1 and only 1 child row (in Band 2).
mac_swit said:The additional data in band 2 should always be shown after the last row of each employee in band 1. Therefore I have to move the childrow in band 2 from one parent to another parent.
Here's where you lost me. Let's take an example where you have a single row in band 0 with 2 child rows. Each child row has a single child row (grandchild row).
Row 0
Row 0, 0
Row 0, 0, 0
Row 0, 1
Row 0, 1, 1
It sounds like what you want to do is this:
If that's the case, then there's no way to do this in the grid. Row 0, 0, 0 is a child of Row 0, 0. You cannot change it's parent row in the grid - you would have to change it in the data source and then the grid would reflect that change.
Hello Mike,
No, not that way. But it's a good idea to visualize it. Starting at this point:
Row 0,0
Row 0,0,0
Row 0,1
Row 0,1,1
At the moment I add (actually insert at the right position) one additional row to each employee data row in band 1. If I don't change the parents, it would look like this (new rows bold font):
Row 0,2
Row 0,2,0
Row 0,3
Row 0,0 and Row 0,1 belongs logically to one employee nad row 0,2 and row 0,3 to the next employee. What I want is that if band 2 rows are visible, they shouls appear after the last row of each employee. Therefore I have to change the parent row to this:
Row 0,1,0
Row 0,3,1
I'm looking now for the best approach achieving this, because I have two grids to keep in synch (second grid with more detailed data about the current column). Modifying the ParentRow property or move the whole child rows collection from one parent to the other to achieve also a good performance.
What is your suggestion to this?
mac_swit said: At the moment I add (actually insert at the right position) one additional row to each employee data row in band 1. If I don't change the parents, it would look like this (new rows bold font): Row 0 Row 0,0 Row 0,0,0 Row 0,1 Row 0,2 Row 0,2,0 Row 0,3
What you have done here is you have add two new rows to Band 1, and both rows were added to the one and only parent row in Band 0. There is no association between these two new rows and the grandchild rows that already exist in Band 2.
So it looks like you want to move the Band 2 rows under these new parent rows - efectively shifting them down. To do that, you would have to modify your data source - there is no way to do this through the grid.
ok, that is what I'm doing so far. What I'm missing are some functionality on the data source to deal with the whole row object. My rows in band 2 can have individual row heights, data, background colors, font styles and row tag object. All these has to be reinitialized to the same for a new added row.
Is there some functionality I probably missing to achieve this more efficient. Something like this:
UltraDataRow oldChildRow = oldParentChildRowsCollection[0];
oldParentChildCollection.RemoveAt( 0 );
newParentChildRowsCollection.Add( oldChildRow ); --> missing
Regards
mac_swit said:My rows in band 2 can have individual row heights, data, background colors, font styles and row tag object.
All of this is on the grid row, not the UltraDataRow (with the possible exception of the Tag property, which exists on both).
There's no one-step way to copy all of this from one grid row to another. You will have to copy the property manually, which means finding the row in the grid both before and after you move the row in the data source.
Typically, the best way to apply appearances, heights, etc. to a row is to use the InitializeRow event. In this event, you examine the row and the value(s) of the cells in that row and then apply whatever font, color, or other appearance settings you want. If you do it this way, then you won't have to worry about copying the appearances from one row to the other, because adding the new row into the grid will fire the event and the code will apply the styling to the cell automatically.