Hey guys,
I'm doing something new to me in that I'm binding an ultragrid to a dataset rather than binding it to a strongly typed collection, so I'm dealing with some issues I haven't had to before. My situation is that I have a dataset that consists of parent datatable and many other datatables that are linked to the parent datatable using data relations.
So far so good... when I bind I get my parent rows and columns that are setup correction and I can expand to see children of each parent row. The problem is that there is no relationship between the columns of the parent row to the columns of the child row. I've tried:
DisplayLayout.Override.AllowColSizing = AllowColSizing.Synchronized
This doesn't seem to have any affect on the table. The parent rows and child rows have exactly the same columns and groups. still, they are unaffecting of each other and I need them to be tied together.
Any advice for this situation? Basically I just need a way to get the child band columns tied to the parent band columns of the same name/key.
Thanks!
Hi,
I'm not sure what you are trying to do here. What kind of effect are you expecting the parent columns and the child column to have on each other?
You seem to be talking about the width of the columns. But the grid linked up the column widths and keeps them in synch by default - you don't have to do anything. The property that controls this is the AllowColSizing property and setting it to Synchronized will keep the columns widths synchronized - but you usually don't have to set this property, since it defaults to Synchronized, anyway.
If the column widths are not synchronized, then my best guess is that something else in your code is setting the AllowColSizing to something other than Synchronized. Perhaps you are loading a Layout or a Preset into the grid?
For reference, here is the grid, fully loaded. I have turned off group headers and column headers on the child band. If I don't use Groups in EITHER band, the columns line up, but once I add the groups, it looks like this:
Okay, that explains it. The columns cannot be synchronized when you are using Groups.
You might be able to handle this in code by explicitly setting the Width on each column and then handling the AfterColPosChanged event to trap when the column sizes are changed and then synchronize the other band. But it would probably be pretty tricky.
Another option would be to remove the groups and then fake groups by using a CreationFilter. But that's not trivial, either.
Since your bands all have the same columns, anyway, a third option would be to re-organize your data source so that all of the data is in a single band and then create a hierarchy out of the data using OutlookGroupBy.
It doesn't look like the OutlookGroupBy method would work as it doesn't show values on the GroupBy row in the grid. I don't think I'd be able to recreate the look from my image using this method.
I don't think the column sizing trick would work very well as I could feasibly have hundreds of child bands.
Can you explain the CreationFilter and how it would help here? I'm unfamiliar with it and a quick search hasn't really helped.
I guess basically my ultimate question is this... you can see from the image what I need... What is the best way to make that happen with an UltraGrid? If OutlookGroupBy can be visually modified to look like my image, I'd probably go that route, as all these child bands are really destroying my load times.
I redesigned the dataset/datatable/datarelations that are bound to the grid so it's much faster... I'm going to go the route of resizing child-band columns when the parent band resizes and see what complications I encounter.
Great, I'm glad you got it working.
To answer your earlier question about the CreationFilter, it would be pretty tricky.
From your screen shot here it looks like you have ColHeaderLines set to 2. So the basic approach I had in mind is that you would set it to 3 to create an extra line of space and remove all groups.
Then your creation filterer would trap for the creation of the child elements of the BandHeadersUIElement. This is the element that contains the column headers and group header (if there are any). The CreationFilter would basically have to shift the column header down and make them one line shorter. And then you would add in your own HeaderUIElements to simulate the group headers.
The down side of the CreationFilter approach is that you would lose the ability to resize the groups - the fake group headers would not respond to mouse clicks on the right edge like real groups do.
So the approach you are using it better in that regard.
ok, just as a follow up... I was able to use a combination of AfterColPosChanged and AfterGroupPosChanged to get the affect I wanted. I set the initial column widths after the datasource is bound and then those two events maintain the widths from there.