Iterating all rows

5 posts, 0 answers
  1. dennis
    dennis avatar
    39 posts
    Member since:
    Jun 2008

    Posted 20 Mar 2009 Link to this post

    how i can iterate all rows in a grid binded by itemssource?.
    i searched in online help but the section is empty.
  2. Rosi
    Admin
    Rosi avatar
    2529 posts

    Posted 23 Mar 2009 Link to this post

    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.
  3. christine
    christine avatar
    17 posts
    Member since:
    Jul 2010

    Posted 29 Sep 2011 Link to this post

    Is there a more current example for doing this or is using the 'Records' property still the correct way?
  4. Vlad
    Admin
    Vlad avatar
    11100 posts

    Posted 30 Sep 2011 Link to this post

    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 >>

  5. christine
    christine avatar
    17 posts
    Member since:
    Jul 2010

    Posted 03 Oct 2011 Link to this post

    Maybe I should clarify on what I am really trying to do, I will start a new thread. 
Back to Top