We have a grid we have bound to an UltraDataSource and set the Load Style on the grid to LoadOnDemand. Our Datasource is set up to have the following structure:
17 Rows at the root
500 child rows for each root level roow
When the grid loads up we notice that the InitializeRow event on the grid is fired for all 500 rows for each parent row. The grid is never told to expand all can you help us understand why all 500 rows for each root level row is initialized given the following:
1. Rows are collapsed so i can only see the 17 parent rows
2. Its a load on demand grid and can only see about 50 rows at any one time.
Any help is appreciated.
There are a number of reasons why the grid might be forced to load all of the rows.
If anything in your code tries to access those rows for any reason, they will need to be loaded. Make sure you are not using sorting or filtering in the grid.
If that does not help, maybe you could post a small sample project demonstrating the issue so I can take a look. If you can provide a sample I can run, then I should be able to tell you why the rows are being loaded.
If you can't create a sample, then another thing that might help is if you could post the call stack for the InitializeRow event for one of the child rows.
After a lot of investigation as our stack trace was fairly slim - UI thread was invoking most of our row initialise calls directly - it seems that you point about iterating over the rows is our culprit. I commented out some of these calls, compromising functionality purely for the test, and it proved that this was our cause. We will implement a different way of providing our functionality that doesn't need to iterate over all grid rows.
Thanks for the help.
One of the main reasons for having the InitializeRow event is so you can avoid looping through the grid rows unnecessarily, so maybe your code can be moved there.