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

Iterating all rows

4 Answers 163 Views
GridView
This is a migrated thread and some comments may be shown as answers.
dennis
Top achievements
Rank 1
dennis asked on 20 Mar 2009, 05:05 PM
how i can iterate all rows in a grid binded by itemssource?.
i searched in online help but the section is empty.

4 Answers, 1 is accepted

Sort by
0
Rosi
Telerik team
answered on 23 Mar 2009, 08:19 AM
Hello Dennis,

Thank you for your interest in our controls.

Please find below a sample function which illustrates how you can complete the task:
   private void IterateRows(IList<Record> records)  
        {  
            foreach (Record record in records)  
            {  
                if (record is ExpandableDataRecord)  //iterates inside hierachy rows
                {  
                    ExpandableDataRecord expandableRecord = (ExpandableDataRecord)record;  
                    IterateRows(expandableRecord.ChildRecordManagers[0].Records);  
                }  
                if (record is GroupRecord)  //iterates inside group rows
                {  
                    GroupRecord groupRecord = (GroupRecord)record;  
                    IterateRows(groupRecord.Records);  
                }  
                rows++;  
            }  
        } 

I suggest you call this method after the grid is bound.

Example
  public partial class Example  
    {  
        public int rows = 0;  
        public Example()  
        {  
            InitializeComponent();  
 
            radGridViewAggregates.ItemsSource = ExamplesDB.GetCustomers();  
            radGridViewAggregates.Loaded += new System.Windows.RoutedEventHandler(radGridViewAggregates_Loaded);  
        }  
 
        void radGridViewAggregates_Loaded(object sender, System.Windows.RoutedEventArgs e)  
        {  
            IterateRows(radGridViewAggregates.Records);  
        }  

Hope this helps.

Regards,
Rosi
the Telerik team

Check out Telerik Trainer , the state of the art learning tool for Telerik products.
0
christine
Top achievements
Rank 1
answered on 29 Sep 2011, 07:20 PM
Is there a more current example for doing this or is using the 'Records' property still the correct way?
0
Vlad
Telerik team
answered on 30 Sep 2011, 06:37 AM
Hello Christine,

You can use RadGridView Items collection to iterate data items. 

Kind regards,
Vlad
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
christine
Top achievements
Rank 1
answered on 03 Oct 2011, 09:49 PM
Maybe I should clarify on what I am really trying to do, I will start a new thread. 
Tags
GridView
Asked by
dennis
Top achievements
Rank 1
Answers by
Rosi
Telerik team
christine
Top achievements
Rank 1
Vlad
Telerik team
Share this question
or