This is a migrated thread and some comments may be shown as answers.

adding rows is very slow?

5 Answers 587 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Louis
Top achievements
Rank 1
Louis asked on 15 Oct 2007, 02:46 PM
I'm trying to add 40 rows in a grid programmaticly like this :

try 
{  
this.Cursor = Cursors.WaitCursor;  
grdSearchResults.SuspendUpdate();  
 
//remove all filters  
foreach (GridViewDataColumn dc in grdSearchResults.MasterGridViewTemplate.Columns)  
  dc.Filter.StringValue = string.Empty;  
 
//add new pax to current manifest  
for (int i = 0; i < nb; i++)  
  paxList.AddNew();  
 
UpdateScreenState();  
 
grdSearchResults.Rows[paxList.Count - nb].IsCurrent = true;  
grdSearchResults.Columns[0].IsCurrent = true;  
grdSearchResults.GridElement.ScrollToRow(0);  
if (grdSearchResults.CurrentCell != null)  
  ((GridDataCellElement)grdSearchResults.CurrentCell).BeginEdit();  
}  
catch (Exception exc)  
{  
  ExceptionPolicy.HandleException(exc, "Client Policy");  
}  
finally 
{  
  this.Cursor = Cursors.Default;  
  grdSearchResults.ResumeUpdate();  

when adding let say 30 rows (nb=30) the grid is extremely slow. Is there something i should do to fasten things up?

I've tried using 

grdSearchResults.GridElement.BeginUpdate();

instead of SuspendUpdate but the grid throws an argument out of range exception stating that Value is out of range???

5 Answers, 1 is accepted

Sort by
0
Julian Benkov
Telerik team
answered on 16 Oct 2007, 11:23 AM
Hello Louis ,

You can replace the Suspend/Resume Update functions with the Begin/End Update functions of the RadGridView GridElement.

Please refer to the codeblock below:

try  
{   
this.Cursor = Cursors.WaitCursor;   
grdSearchResults.GridElement.BeginUpdate();   
  
//remove all filters   
foreach (GridViewDataColumn dc in grdSearchResults.MasterGridViewTemplate.Columns)   
  dc.Filter.StringValue = string.Empty;   
  
//add new pax to current manifest   
for (int i = 0; i < nb; i++)   
  paxList.AddNew();   
  
UpdateScreenState();   
  
grdSearchResults.Rows[paxList.Count - nb].IsCurrent = true;   
grdSearchResults.Columns[0].IsCurrent = true;   
grdSearchResults.GridElement.ScrollToRow(0);   
if (grdSearchResults.CurrentCell != null)   
  ((GridDataCellElement)grdSearchResults.CurrentCell).BeginEdit();   
}   
catch (Exception exc)   
{   
  ExceptionPolicy.HandleException(exc, "Client Policy");   
}   
finally  
{   
  this.Cursor = Cursors.Default;   
  grdSearchResults.GridElement.EndUpdate();   
}  

I hope this was helpful. If you have any additional questions, please contact us again.

Regards,
Julian Benkov
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Louis
Top achievements
Rank 1
answered on 16 Oct 2007, 06:11 PM
I've tried what you said but it throws me an exception stating that value is not between minimum and maximum ?? i will open a supprot ticket and paste a picture of the error.


0
Dwight
Telerik team
answered on 17 Oct 2007, 07:41 AM
Hello Louis,

Please, find the answer to your question in the support area.

Regards,
Evtim
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Jared
Top achievements
Rank 1
answered on 23 Oct 2014, 03:02 PM
Since this post is old I thought I'd add what I did to solve this exact problem.  The .BeginUpdate() / .EndUpdate() calls certainly worked.  But now those methods are on the grid object themselves.  So in the OP's code the two calls would look like this:

grdSearchResults.BeginUpdate();

grdSearchResults.EndUpdate();

This really helped improve performance while I was programmatically creating rows.   
0
George
Telerik team
answered on 28 Oct 2014, 09:56 AM
Hi Jared,

Thank you for providing the community with an update on the specific scenario. Indeed, the Begin/EndUpdate methods are on the control itself and on the MasterTemplate as well:
this.Grid.MasterTemplate.BeginUpdate();
this.Grid.MasterTemplate.EndUpdate();

Regards,
George
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
GridView
Asked by
Louis
Top achievements
Rank 1
Answers by
Julian Benkov
Telerik team
Louis
Top achievements
Rank 1
Dwight
Telerik team
Jared
Top achievements
Rank 1
George
Telerik team
Share this question
or