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

How to iterate in GridRows

4 Answers 91 Views
GridView
This is a migrated thread and some comments may be shown as answers.
4ward s.r.l.
Top achievements
Rank 1
4ward s.r.l. asked on 09 Nov 2009, 11:59 AM
In 2009 Q2 we were using following code to iterate through GridRows in order to collect all rows:

 

 

 
  public IEnumerable GetSelectedRecords  
        {  
            get 
            {  
                 
                List<object> selectedRecords = new List<object>();  
                IList<GridViewRow> rows = EmployeeGridView.ChildrenOfType<GridViewRow>();  
                int index = 0;  
                foreach (GridViewRow row in rows)  
                {  
                 if (!(row is GridViewNewRow) && !(row is GridViewHeaderRow))  
                    {  
                        CheckBox checkBox = row.Cells[0].ChildrenOfType<CheckBox>().FirstOrDefault();  
                        if (checkBox != null && checkBox.IsChecked == true)  
                        {  
                            selectedRecords.Add(row.Item);  
                        }  
                    }  
 


and rows above contained all records in the Grid. Now with Q3 it contains only visible rows. Can this behaviour be overridden in some way ? Or is there a new way to do the same operation ?

Thanks and regards,

Ivan

 

4 Answers, 1 is accepted

Sort by
0
Accepted
Milan
Telerik team
answered on 09 Nov 2009, 01:15 PM

Hello 4ward s.r.l.,

Well, you could easily turn off the virtualization mechanism by setting EnableRowVirtualization to false, which will disable our virtualization logic and all row will be created. But I guess turning of the virtualization is undesired since it will have a noticeable performance impact.

As far as I can see you are determining how many checkboxes are checked. We have recently introduced a new column type called GridViewSelectColumn which can talk to our internal selection mechanism - when you check a checkbox its parent row is automatically selected and added to our SelectedItems collection. That way you can easily determine the selected / checked rows by just observing myGrid.SelectedItem.Count property.

Here you can take a look a the grid view select column. 


Greetings,
Milan
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
TSRG - IT
Top achievements
Rank 1
answered on 23 Nov 2009, 07:31 AM
Hi, is it possible to disable rows when only the groupings are visible (rows not visible)? I.e permanently disable certain rows.

Cheers,

Tim.
0
Vlad
Telerik team
answered on 23 Nov 2009, 09:01 AM
Hi Tim,

You can use RowLoaded to achieve your goal. Please check the attached project for reference.

Best wishes,
Vlad
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
TSRG - IT
Top achievements
Rank 1
answered on 24 Nov 2009, 07:13 AM
Thank you very much, that's it!
Tags
GridView
Asked by
4ward s.r.l.
Top achievements
Rank 1
Answers by
Milan
Telerik team
TSRG - IT
Top achievements
Rank 1
Vlad
Telerik team
Share this question
or