I have application that creates/removes rows and UltraDataBands in my UltraDataSource but very quickly my ultraGrid gets out of synch with the datasource. When I examine ultragrid.DisplayLayout.Bands collection it has multiple duplicated entries with the same key which I believe cause the problem. In my case I assign RowLayout to a band "Involuntary Assumptionnt" and it works fine the first time when there is only 1 grid band with that key in the DisplayLayout.Bands collection. After I remove and add back that band and rows several times I have multiple identical grid bands in DisplayLayout.Bands and RowLayout does not show up in the grid.
Here is a copy of my ultragrid.DisplayLayout.Bands view in the Watch window - notice identical bands #3, 4 and 6
- ultraGrid1.DisplayLayout.Bands.All {Infragistics.Shared.IKeyedSubObject[7]} object[] {Infragistics.Shared.IKeyedSubObject[]}+ [0] {Band 0} object {Infragistics.Win.UltraWinGrid.UltraGridBand}+ [1] {Prepayment Assumption} object {Infragistics.Win.UltraWinGrid.UltraGridBand}+ [2] {Involuntary Assumption} object {Infragistics.Win.UltraWinGrid.UltraGridBand}+ [3] {Involuntary Assumptionnt} object {Infragistics.Win.UltraWinGrid.UltraGridBand}+ [4] {Involuntary Assumptionnt} object {Infragistics.Win.UltraWinGrid.UltraGridBand}+ [5] {MIAC RowLayout} object {Infragistics.Win.UltraWinGrid.UltraGridBand}+ [6] {Involuntary Assumptionnt} object {Infragistics.Win.UltraWinGrid.UltraGridBand}
I'm not sure if I'm doing something I'm not supposed to or it's a bug or what but I spent nearly a week banging my head against the table trying to figure this one out.
Please help.
Hi Lev,
Can you provide a small sample project demonstrating this behavior? Without a sample, I don't see any way I could even begin to guess how this might happen.
Mike,
I'll try to put together a sample but it might be difficult since that code is part of a very large application.
There is no way to add/remove display bands since they are driven by datasource - but is there a way to reinitialize grid so that those duplicated bands go away? Set DataSource to null and back to datasource will probably work but it looses all display formatting. Saving DisplayLayout to XML and back saves and restores most of the formatting but still does nothing for cell editors for example and I get corrupted XML files every ones in a blue moon. Is there a better way to reinitialize grid's data?
Lev said:There is no way to add/remove display bands since they are driven by datasource - but is there a way to reinitialize grid so that those duplicated bands go away?
Ideally, the best thing to do would be to define the data structure up front and not change it. :)
But if that's not possible, I don't think there is any way to get the grid to refresh it's data structure. In theory, it should never be out of synch, although there are times when the grid may decide not to load child bands from the data source until they are needed.
You can try calling grid.Rows.Refresh and experimenting with the different options. I double that will have any effect on the bands, but I could be wrong and it couldn't hurt to try.