I have a multiband grid where I want to create child bands when the expansion indicator is selected on the parent band. I put code to do this in the BeforeRowExpanded event but the expansion indicator disappears like there is no child data. I am manually creating records in the dataset that is bound to the grid. do I have to refresh the grid maybe?
Hi,
I would advise against this. The grid is really not designed to handle dynamically added and/or removed bands.The grid's data structure has to be homogenous, so it's more efficient and easier to set up the band structure up front.
Having said that, what you probably need to do is call grid.Rows.Refresh to force it to reload the data.
my post may have not been very clear...
the datasource structure for the grid is static - all I am doing is adding data to the datasource when the beforerowexpand grid event fires. The refresh method works fine and I got it working, sort of.
One problem that I haven't been able to solve is that if the first row that I attempt to expand is the first row in the grid, the expansion indicator disappears like there was no child data. If I click to expand another row and then click to expand the first row, it works correctly. In both cases, the child data for the first work is build properly.
I'm afraid I'm having trouble following what you are describing. There are a huge number of factors at play here and it's really impossible for me to guess what's not working here and why.
Perhaps what you could do is create a small sample project demonstrating the issue so we can take a look.
I'm having the exact same issue.
I have a list of objects bound to the UltraGrid. In the BeforeRowExpanded event handler I load data for Band1 of the grid. The event handler looks like this:private void gridHealthRecord_BeforeRowExpanded(object sender, Infragistics.Win.UltraWinGrid.CancelableRowEventArgs e){ ReLoadSubData(e.Row.ListObject);}
If I click the expand button of a row that is NOT currently selected, the event fires, data is loaded and shown in the band 1 of the grid correctly.
If I click the expand button of a currently SELECTED row, the event fires too, and the data is loaded into the object hierarchy, however the expand button of the selected row disappears and the child band is not expanded.If I then select another row and then select the previously selected (and expanded) row again, the expand button appears and the child band of the expanded row is visible.
I tried to add various Refresh and Invalidate triggers into the event, posted above, but it did not help to resolve the issue.
Any help would be greatly appreciated.
In this case, my guess is that the problem is that you are using a List. I assume by List, you mean you are using a List<T> or some other class which implements IList. IList is not generally a good class to use for DataBinding because IList doesn't send notifications when items are added to the list.
I recommend using an IBindingList, like BindingList<T> instead of an IList.
Another option is to force the grid to refresh itself by calling grid.Rows.Refresh(ReloadData). You might have to call this both on the parent rows of the grid and the child rows of the particular row you expanded.
Sorry for the late reply.
I have tried the second solution and it works now. The first solution - using the BindingList that implements list change notifications - seems a better one in terms of performance, but it will take some time to change the definitions and all references to it, so I'll try that later.
Anyway, thank you for your help!!