Hi,I am using UltraGrid 10.1.2 and the code below to bind it to a list of custom objects. If I change the MaxBandDepth to be 1 it is quick so it must be opening up the child bands even though I have Loadstyle set to LoadOnDemand, this is confirmed when I trace it and can see that on the line this.bLDepartmentUltraGrid.DataSource = bLDepartmentBindingSource; the code is going into one of the child objects.
Is there a way to stop the code getting the child data until the uses selects that child ? I was hoping the that LoadOnDemand would have done this
this.bLDepartmentUltraGrid.DisplayLayout.LoadStyle = LoadStyle.LoadOnDemand;this.bLDepartmentUltraGrid.DisplayLayout.MaxBandDepth = 3;this.bLDepartmentBindingSource.RaiseListChangedEvents = false;this.bLDepartmentBindingSource.DataSource = AllDepartments;this.bLDepartmentUltraGrid.DataSource = bLDepartmentBindingSource;this.bLDepartmentBindingSource.RaiseListChangedEvents = true;
Thanks John
Hi John,
I'm confused by what you are trying to do.
Do you want your grid to load the child bands or not? You seem to be saying that you DO want the grid to show the child data, but only after the user expands a parent row. But in that case, setting MaxBandDepth to 1 will not work, because this will prevent the grid from ever loading any child data.
In any case, if your child data is being accessed before a parent row is expanded, it might be just because the BindingManager in DotNet is trying to get the data structure so that the grid can build the bands. There is no way to prevent that, but it should just be a single row, so it's really not a big deal.
Hi Mike,
Yes apologies I wasn't clear. The reason I mentioned setting MaxBandDepth to 1 (which made things very quick) was to prove that the grid must be doing something with the child bands as when I set MaxBandDepth=3 it was a lot slower. The difference in time is instant when MaxBandDepth=1 to about 6 seconds with MaxBandDepth=3. But yes ultimately I need MaxBandDepth to be 3 so that I get the child bands
Ideally I would like the grid to do nothing with the child bands until the User tries to expand one but you say this is not possible, can you confirm that this is the case even with later version of the grid
Also I think that my performace problem lies in the fact that my objects are deep and complex and recursive so possibly the binding manager ends up doing a lot of work to discover the structure when MaxBandDept=3. I dont suppose there is anything I can do to improve this
It's hard to say exactly what's going on. If you have MaxBandDepth set to 3, then the grid is probably creating the data structure of all three levels up front, and depending on what kind of data source you are using, the BindingManager may need to access a row at each level. But even if that's the case, it shouldn't take long - it would just be accessing a single row.
If you are saying that the grid is accessing multiple child and/or grandchild rows of your data, then something else is going on there.
The whole point of using the grid on-demand is that it does not load the child rows until they are needed, but there are all sorts of settings in the grid that could force the rows to be needed immediately. For example, if you set the ExpansionIndicator property to CheckOnDisplay, then when the parent row is displayed, the grid would have to check for the existence of child rows under every displayed parent row and that would cause the data to be loaded.
So basically what I'm saying is that there just isn't enough information here for me to go on.
Can you reproduce the issue in a small sample project I could run? If so, you can post it here and I'd be happy to take a look at it for you.
Thank you for your offer to look at a sample project for me which I am happy to do but it will take me quite a bit of time to set it up. Berfore I do this are you able to point me to the grid settings and values that should be set in order for the rows NOT to be needed immediately ? I can then try those and if that doesn't work I can then build the sample project for you to look at
I don't have a complete list. But the example I gave of the ExpansionIndicators property is basically the kind of thing you have to watch out for. Anything that would require the grid to load the child rows will do so. If you called the ExpandAll method, or performed filtering or sorting on a child band.
It's still not clear to me whether you are seeing only a single row in the child band being accessed or all of the rows? If it's more than one row, then looking at the call stack and seeing how it got to that point might be helpful, also.