I found that UltraGrid is very slow to refresh after i make changes to the attached UltraDataSource. I followed Mike's article about UltraGrid's performance and added
this.ultraGrid1.BeginUpdate();this.ultraGrid1.SuspendRowSynchronization();
and corresponding Resume and EndUpdate functions but that didn't improve matters much. After some experimenting I got reasonable performance if I just set DataSource of my grid to NULL, do changes to data source and then assign my data source back to grid.
I just think I'm missing something here.
What kind of changes are you making?
Any time you make a change to the data source, like adding, deleting, or editing rows, the data source notifies the grid of the change and the grid responds. So if you make a lot of changes all at once, it can be a performance issue.
BeginUpdate tells the grid not to paint, so that will help improve performance.
SuspendRowSynchronization tells the grid not to synchronize the rows, so that will help some more.
But there is still some processing going on in the grid. So if those methods don't help, then we'd have to know exactly exactly what you are doing to the data source and consequently what notifications the grid is getting so we could see why the grid is slow.
If you can duplicate the problem in a small sample project, we could check it out and maybe improve the performance or give you tips on how you can make it faster.
Hi,
I am calling "grid.UpdateData()" method after modifying data from code behind. It is taking too much time. My code as below:
for (int i = 0; i < grid.Rows.Count; i++){ UltraGridRow row = this.Rows[i]; row.Cells[this.ActiveCell.Column].Value = this.ActiveCell.Value; }
grid.UpdateData();
So here if I am updating 80k records then this for loop takes ~10sec and "grid.UpdateData()" method takes ~80sec.
Is it usual?
Or is there any better way to implement it?
Thanks,
Sunil
Thanks Mike for the prompt response.
Here is very simple sample code I put together that illustrates the problem. Without resetting DataSource it runs for ~8 seconds. When you first set DataSource to null, do your changes and set it back to ultraDataSource it takes less than a second.
//ultraGrid1.DataSource = null;this.ultraGrid1.BeginUpdate();this.ultraGrid1.SuspendRowSynchronization();try{ UltraDataRow row = ultraDataSource1.Rows.Add(new object[] { "Data1", "Data2", "Data3", "Data4", "Data5" }); for (int i = 0; i < 30; i++) { UltraDataBand band = ultraDataSource1.Band.ChildBands.Add(i.ToString()); //don't know if there is an easier way to inherit parent band's columns foreach (UltraDataColumn column in ultraDataSource1.Band.Columns) band.Columns.Add(column.Key, column.DataType); UltraDataRow row2 = row.GetChildRows(band).Add(new object[] { "BandA", "Data2", "Data3", "Data4", "Data5" }); } //ultraGrid1.DataSource = ultraDataSource1;}finally{ this.ultraGrid1.ResumeRowSynchronization(); this.ultraGrid1.EndUpdate();}