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

SelectAll() Within RadPanelBar

3 Answers 38 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Scott
Top achievements
Rank 1
Scott asked on 12 Apr 2011, 06:42 PM
I have a RadGridView that is sitting inside a RadPanelBar.  When I add data to the GridView, I want to make sure all the rows are selected with SelectAll().  This works fine as long as the RadPanelBar has been expanded at least once, but when the application first starts up, the GridView is hidden and the call to SelectAll() does not work  I'm assuming this is due to the fact that the grid is not instantiated yet since the XAML has not been hit.

What is the proper way to be able to interact with a RadGridView (or any control for that matter) that sits within a PanelBar or an Expander?  I'd like to be able to interact with the control whether it is visible or not.

As a side note, I thought I could just use the DataLoaded event to make sure that each time new data made it to the Grid, I could call SelectAll() since I want every row selected when new data is being entered.  However, this does not work for me since when clicking a column heading to sort, the DataLoaded event gets fired again.  I just need to know the proper way to interact with a control that may or may not have been visible prior to calling methods on it.

Thanks,

-Scott

3 Answers, 1 is accepted

Sort by
0
Ivan Ivanov
Telerik team
answered on 13 Apr 2011, 08:53 AM
Hello Scott,

You cannot interact with these GridViewRows before they are added to the visual tree. You may try subscribing to RadGridView's RowLoaded event and select each row as soon as it is successfully loaded. Please, refer to the attached example and inform us if this approach meets your requirements.

Regards,
Ivan Ivanov
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
Scott
Top achievements
Rank 1
answered on 13 Apr 2011, 04:18 PM
Ivan,

The issue with subscribing to RowLoaded and selecting all rows is that any time the grid is sorted (clicking a column heading), all rows are selected again.  I want to be able to make sure all rows are selected by default the very first time the gird is viewed, but I want to allow the user to deselect rows and use the grid normally after that. 

Using the RowLoaded event gets me half way there.  Is there a way within the event handler to know what caused the event?  If I knew the event was fired from a sort, I would just ignore it.

Do you have any other suggestions on how I may be able to fix this?

Thanks,

-Scott
0
Ivan Ivanov
Telerik team
answered on 18 Apr 2011, 04:18 PM
Hi Scott,

I have prepared a workaround for you. Please, check the updated version of my initial example project. 

Regards,
Ivan Ivanov
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
Tags
GridView
Asked by
Scott
Top achievements
Rank 1
Answers by
Ivan Ivanov
Telerik team
Scott
Top achievements
Rank 1
Share this question
or