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

Iterating Rows in GridView Slow

1 Answer 156 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Dan
Top achievements
Rank 1
Dan asked on 27 Aug 2008, 11:32 PM

Why does iterating through the rows in the grid take so long like in this example.  It can take a few minutes to walk through every row in the grid if it contains 10000+ rows.  Is there a more efficient way to walk the rows.  I am trying to implement a find within a column functionality, but it is extremely slow for a large number of rows.



for
(int i = 0; i < Global.MainUiForm.OutputGrid.RowCount; i++)

{

currentRow =

Global.MainUiForm.OutputGrid.MasterGridViewInfo.Rows[i];

radColumn = (

RadColumn)this.comboBoxLookIn.SelectedItem;

if (regex.IsMatch(currentRow.Cells[radColumn.FieldName].Value.ToString()))

{

currentRow.IsCurrent =

true;

currentRow.EnsureVisible();

currentRow.Cells[radColumn.FieldName].EnsureVisible();

found =

true;

break;

}

}

1 Answer, 1 is accepted

Sort by
0
Mike
Telerik team
answered on 28 Aug 2008, 03:12 PM
Hi Dan,

The slow iteration through the grid rows in your case happens, becuase the GridViewInfo.Rows property is calculated at each request, based on the UI state of the current GridViewInfo - for example these are the rows in one sub-detail view in the hierarchy. This might be useful when working in hierarchy mode.

In your case though, you should use another property: RadGridView.Rows or RadGridView.MasterGridViewTemplate.Rows. Both are references to the actual rows collection, bound to the underlying data, and processed by grid's automatic filtering, grouping, and sorting features.

I noticed that the API reference in our documentation does not explain this difference very well and I'll add this improvement as a to-do item for the next version.
 

Greetings,
Mike
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
GridView
Asked by
Dan
Top achievements
Rank 1
Answers by
Mike
Telerik team
Share this question
or