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

Access RowDetails when it's not already loaded

4 Answers 68 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Joachim
Top achievements
Rank 1
Joachim asked on 08 Dec 2010, 03:59 PM
Hi Telerik Team !

I have a RadGridView with rows.
I have an edit button within each rows.
When I click on the edit button I want to access on an element in the row's details view even if it has never been loaded.

I have a click event handler like this :
private void btnEdit_Click(object sender, RoutedEventArgs e)
{
      GridViewRow _currentRowEdited = (sender as UIElement).ParentOfType<GridViewRow>();
      Grid rowDetailsGrid = (Grid)_currentRowEdited.ChildrenOfType<DetailsPresenter>()[0].Content;
}

But when the row details has never be loaded the line _currentRowEdited.ChildrenOfType<DetailsPresenter>() returns null...

Please, how can I achieve what i want ?

Thank you in advance,

Joachim.

4 Answers, 1 is accepted

Sort by
0
Veselin Vasilev
Telerik team
answered on 08 Dec 2010, 04:25 PM
Hello Joachim,

You cannot access the controls as the details are not loaded. Why do you need that?
Why not loading the row details? There is an event - LoadingRowDetails which might be of help.

Let us know more about your scenario so we can advise you.

All the best,
Veselin Vasilev
the Telerik team
Browse the videos here>> to help you get started with RadControls for Silverlight
0
Joachim
Top achievements
Rank 1
answered on 10 Dec 2010, 09:35 AM
Hello Veselin,

I need to do that in order to hide some controls in the row details when the user click on the edit button.
I don't want to force the loading of the row details, but if the user load the row details after clicking the edit button, i need to hide some controls within it...

If i well understood, i have to listen the LoadingRowDetails event and if i am in Edit mode (after clicking edit button)I hide the controls in the listener ? Is it a good way ?

Thank you for your help Veselin.
0
Accepted
Rossen Hristov
Telerik team
answered on 10 Dec 2010, 02:32 PM
Hello Joachim,

You can't perform an action on something that has not even been "born". What you want to do is hide/show certain elements based on certain criteria. This can be achieved in three ways:

1. In case the possible combinations of templates are not very much you can use a RowDetailsTemplateSelector and select a different template for each row based on certain criteria.

2. Add new properties to your business object class that will control the visibility of certain elements inside the row details. Each of these elements' Visibility can be bound to a property on the business object telling it whether to show or hide.

3. Attach to either the LoadingRowDetails (fired just once when the details are loaded) or RowDetailsVisibilityChanged events (fired each time details are shown or hidden). In the event handler do the housekeeping and hide/show certain controls. This is not quite MVVM though.

I hope this helps.

Kind regards,
Ross
the Telerik team
Browse the videos here>> to help you get started with RadControls for Silverlight
0
Joachim
Top achievements
Rank 1
answered on 13 Dec 2010, 09:21 AM
Thank you for your help Ross !
I choose solution 2 !
You are right solution 3 is not very good... and solution 1 could be a good idea but i have a lot of template's combinations.

You are the best guys,

Joachim.
Tags
GridView
Asked by
Joachim
Top achievements
Rank 1
Answers by
Veselin Vasilev
Telerik team
Joachim
Top achievements
Rank 1
Rossen Hristov
Telerik team
Share this question
or