I have the following code to remove a column:
ultraDataSource1.Band.Columns.Remove(colKey); UltraDataBand band = ultraDataSource1.Band; while (band.ChildBands.Count > 0) { band = band.ChildBands[0]; band.Columns.Remove(colKey); }
Removing the column from the final band takes a long time. My data is setup as follows:The initial band contains about 30 rows of data, and each of those contains about 30 rows in their child band. Then each of those child rows has one or two rows in the band below it.
Is there a way to speed up removal of a column?
Thanks.
-Nick
Hi Nick,
I'm not sure why the last column would take any longer than the first one. But this seems very inefficient to me, anyway. Why remove each column indivudually? If you do it this way, then the UltraDataSource is going to send a notification to every bound control upon the removal of each column. So the controls are going to update themselves multiple times. It would probably be a lot faster and more efficient to call band.Colmuns.Clear() or maybe band.Reset().
That seems like it will clear all the columns. What if I want to remove just one column?
Ah, well, your loop here is removing all the columns.
If you just want to remove one column, then I'm not sur. The grid is probably getting a PropertyDescriptorChanged notification. I'm not sure what the grid has to do in terms of processing this, so I can't say why it would take a long time. InitializeRow probably fires for every row.
Is it slow if you do this with the UltraDataSource when it is not bound to the grid? Or is it only slow when the grid is bound?
colKey is the key of the column to be removed.
I've attached the source code to my project and the method that's taking a long time is TraverseRowsCollections.
Are you recommending I unbind the grid, remove the column, and then rebind it?
Well, you might try that and see what happens. At the very least it will tell us whether the slow-down is being caused by the grid or the data source.
If it's TraverseRowsHelper, then it might that something is looping through all the rows of the grid. As I think I mentioned earlier, removing a column will cause the InitializeRow event to fire, so if you are doing some heavy processing inside that event, it may be slowing things down.
Well, the only thing I can suggest at this point is that you create a small sample project that demonstrates the issue and Submit an incident to Infragistics Developer Support so they can see why it's taking so long.
I never set the InitializeRow event to anything.
Unbinding and rebinding doesn't speed it up.