I'm attempting to upgrade my code from Infragistics 8.3 to 9.1. In 8.3, clearing a data source's child band would also clear all child bands in the grid it's attached to. In 9.1, it appears to only clear the immediate child band, and the grand child becomes the child of the root. Is this expected behavior? Or is there another way to clear the children?
Thanks.
-Nick
Hi Nick,
What you are describing does not seem possible. The grid gets it's structure from the data source. If you are saying that the clearing of the child band is somehow creating a relationship between the parent band and the grandchild band then the data source must be doing this, there's no way it can possibly be done by the grid. Unless something is seriously wrong.
In order to reproduce this, create a new windows project, and drop an ultragrid and an ultradatasource onto a form. Tell the grid you'll bind the schema at runtime. Then create the method:
private void SetupGrid(){ ultraGrid1.DataSource = ultraDataSource1; ultraDataSource1.Band.Key = "Totals"; ultraDataSource1.Band.Columns.Clear(); ultraDataSource1.Band.ChildBands.Clear(); ultraDataSource1.Band.Columns.Add("Totals", typeof(string)); UltraDataBand band = ultraDataSource1.Band; int index = 1; for(int i = 0; i < 2; ++i, ++index) { string nameToUse = "col" + i.ToString(); UltraDataBand childBand = band.ChildBands.Add(nameToUse); childBand.Columns.Clear(); childBand.Columns.Add(nameToUse, typeof(string)); //m_bands.Add(childBand); ultraGrid1.DisplayLayout.Bands[index].Override.FixedRowStyle = FixedRowStyle.Top; ultraGrid1.DisplayLayout.Bands[index].ColHeadersVisible = false; ultraGrid1.DisplayLayout.Bands[index].Columns[nameToUse].ColSpan = 1; band = childBand; }}
In your constructor, call SetupGrid twice and it will crash on the second call of the function when it attempts to set ColSpan to 1 because it can't find the column. This works fine in 8.2 and 8.3.
Hi,
I created a sample as you describe with the code here and I am getting some very weird results. The grid seems to end up with the child bands reversed somehow. So there definitely seems to be a problem here.
I am able to reproduce the issue in the latest service release of v8.2, also. So it looks like this was probably broken by a fix for another issue.
I'm going to forward this thread along with the sample I created over to Infragistics Developer Support so they can check it out.
On a different note, the code you have here is a bit unusual. Every time you modify the data source, it will send a notification to the grid and the grid will be updated. So changing the structure of the data source while it is bound to the grid is something you should avoid, if possible.
It would be more efficient to set the grid's DataSource to null, set up the DataSource structure independently, then bind it to the grid and use the InitializeLayout event of the grid to set up the grid's layout for things like ColSpans.
Clearly the current behavior is a bug and needs to be fixed - especially if it worked in a previous version and was broken. But you might want to try re-arranging the code to both make it more efficient and at the same time work around the bug.