I have run into a strange performance issue(and strange solution) when binding to a data tabe. I can't find the answer in this thread (http://forums.infragistics.com/forums/t/15306.aspx) but maybe you would know what is happening. It appears that binding gets exponentially slower the more columns are grouped at the top of the grid.
A few starting points:
-I'm not overriding any painting of the grid
-I have some column value lists, but they are not causing any exceptions to be thrown
-I'm not using a recursive data source. I'm only bind to one data table with no relations. Only one band.
-I'm using a binding source
-I'm using .NET 2.0 and UltraGrid 7.3.1043
-I have ZERO events attached to the grid. So I'm not even running any code outside the grid itself.
The code is very simple:
BindingSource bindingSource = new BindingSource(dataTable, null);GridSummary.DataSource = bindingSource;
The datatable in this example contains less than 500 rows. When I execute this code with no groupings I get a normal binding performance(I.e. less than a second). With one grouping(on a datetime field with mask) it takes about 3 seconds. Add another grouping(column with value list) it takes about 15 seconds. Add another grouping(another datetime) and it jumps to over a minute or longer.I'm mentioning what types of columns the groupings are, but it doesn't seem to matter in my testing. If I break while it is locked up at this point. It breaks on the one line:
GridSummary.DataSource = bindingSource;
The full minute is being used on this one line. I can find no code of my own actually executing during this minute. Strangely enough, if I just manually remove all three groupings(on the screen), re-bind, and then put them back, it takes much less time then re-binding with the groupings(about 10 seconds).
Now I have found a solution, but I'm not sure why it is needed:
I changed the above binding code to look like:
if (m_BoundDataTable != null){//if we're already bound to something
//clear data source without resetting the appearance BindingSource emptyBindingSource = new BindingSource(m_BoundDataTable.Clone(), null); GridSummary.DataSource = emptyBindingSource;}
BindingSource bindingSource = new BindingSource(dataTable, null);GridSummary.DataSource = bindingSource;m_BoundDataTable = dataTable;
Now with this code everything works very quickly(I.e. less than a second), regardless of how many columns I have grouped
So after this long post...my question is: Is this a bug? Or is there something I'm doing wrong?
Even if you don't know why it is happening I would imagine this might solve some other peoples issues in this thread. I imagine it is fairly common to have groupings set up when binding to a datasource. I have not tested if having multiple bands might also cause this issue...
Thanks!
I can't think of any reason why the grid should get exponentially slower in this case. Which is not to say that there is not a reason. But it's probably worth looking into. I recommend that you create a small sample project demonstrating this issue and Submit an incident to Infragistics Developer Support so they can take a look. My guess is that there's probably some code in the grid that is not absolutely as efficient as it could be and it should be corrected.
Oh... but before you submit it, you should probably get the latest hot fix. I'm pretty sure 1043 was not the last one. Perhaps the issue is already corrected. :)
I forgot to mention. This issue only occurs on REBINDING. I.e. the grid has to already be bound to a datatable to get the performance issue. The very first time the grid is bound there is no issue at all no matter how many columns are grouped. That is why the code has the condition to check if it is already bound...