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

Rowloaded exception when scrolling

7 Answers 52 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Richard Averett
Top achievements
Rank 1
Richard Averett asked on 07 Jul 2010, 09:10 PM
I am running into an issue when using the Gridview. I have a Gridview which has the columns defined declaratively in the xaml. There are several controls such as buttons, checkboxes, etc... in the column definitions. I use the GridViewColumns as illustrated below:

                    <telerik:GridViewColumn> 
                                <telerik:GridViewColumn.CellTemplate> 
                                    <DataTemplate> 
                                        <CheckBox VerticalAlignment="Center" x:Name="NextQueue"></CheckBox> 
                                    </DataTemplate> 
                                </telerik:GridViewColumn.CellTemplate> 
                            </telerik:GridViewColumn> 

I set the commandparameters of these elements in the rowloaded event on the GridView. Everything works fine until I scroll the gridview. The rowloaded event throws multiple errors. It appears that several of the elements that are available when the row loaded event first fires are not available when the rowloaded event fires when the scrollbar is used. For example here is how I access one of the checkboxes in the rowloaded:

var row = e.Row as GridViewRow; 
 
var selectedButton = row.Cells[0].ChildrenOfType<CheckBox>()[0]; 
selectedButton.CommandParameter = targetDub; 

When this runs when the grid is initially loaded it works fine. As soon as the user scrolls the grid it throws an exception because the row.Cells[0].ChildrenOfType<CheckBox>() returns a count of 0. This is the case when I try to find any of the controls on that row.

What could be causing this?

7 Answers, 1 is accepted

Sort by
0
Richard Averett
Top achievements
Rank 1
answered on 08 Jul 2010, 04:57 PM
Any Telerik admins have any ideas. We have to deploy soon and at this point I am stuck
0
Yavor Georgiev
Telerik team
answered on 08 Jul 2010, 05:00 PM
Hello Richard Averett,

 I'm not sure changing CommandParameter like this is a wise choice. Is there no other way to expose the data to your ViewModel?

Kind regards,
Yavor Georgiev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Richard Averett
Top achievements
Rank 1
answered on 08 Jul 2010, 05:07 PM
That isn't really the issue. As soon as I scroll the gridview the rowloaded event cannot find any of the controls in the row. One other thing that I noticed is even if I remove the rowloaded event the columns in the rows display the incorrect data field. So for example, if I have a gridViewColumn which uses the DataMemberBinding attribute to state which data field should be used. When the grid initially loads the columns are displaying the correct member. As soon as you scroll, the columns that were not on the screen are showing a completely different data field.
0
Yavor Georgiev
Telerik team
answered on 08 Jul 2010, 05:09 PM
Hi Richard Averett,

 This sounds like a virtualization issue. What version of our controls are you using? Also, what happens if you turn virtualization on the GridView off?

Best wishes,
Yavor Georgiev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Richard Averett
Top achievements
Rank 1
answered on 08 Jul 2010, 05:19 PM
I'm assuming your talking about the IsVirtualizing property. It won't let me set that value on the RadGridView. Says it is read only.  Also, I am using 2010 Q1 SP2 version of the controls.
0
Yavor Georgiev
Telerik team
answered on 08 Jul 2010, 05:27 PM
Hello Richard Averett,

 I mean the EnableRowVirtualization and EnableColumnVirtualization properties.

Regards,
Yavor Georgiev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Richard Averett
Top achievements
Rank 1
answered on 08 Jul 2010, 05:33 PM
That did the trick. I'm never going to be displaying more than a couple hundred rows in this grid anyway so I'll just leave it off.
Tags
GridView
Asked by
Richard Averett
Top achievements
Rank 1
Answers by
Richard Averett
Top achievements
Rank 1
Yavor Georgiev
Telerik team
Share this question
or