What am I missing? What is the correct way of doing this?
Thanks in advance,
-OmarV
10 Answers, 1 is accepted
Hello D. Omar,
I may suggest the following approach :
Subscribe to ExpanderRowStateChangedEvent the following way:
| this.AddHandler(GridViewExpandableRow.ExpanderRowStateChangedEvent, new RoutedEventHandler(OnExpanderRowStateChangedEvent), true); |
This event will fire after the user has pressed the expand button .
Within the event handler you may get acces to the expandableRow this way :
| void OnExpanderRowStateChangedEvent(object sender, RoutedEventArgs args) |
| { |
| GridViewExpandableRow expandableRow = ((RadRoutedEventArgs) args).Source |
| } |
After you have got the reference to rhe expandableRow , you may set its DataContext , manipulate contained controls. ( e.g. set explicitly datasource).
In case you have any troubles with that , just let me know. I will gladly prepare a sample for you .
All the best,
Pavel Pavlovthe Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
I am actually using the OnExpanderRowSTateChanged event, the difference is that I used 'sender' instead of 'args':
| GridViewExpandableRow expandableRow = (GridViewExpandableRow)sender |
What is the difference?
But this does not solve my problem, I am using this event's handler to call the WCF service that is going to get me the data source for my details row, the DataContext for my user control in my HierarchyChildTemplate, which is going to come back asynchronously. Right now what I am doing is listening to the "Loaded" event of my HierarchyChildTemplate user control and storing a reference to it in a dictionary with my ID property as the key, then when the WCF service calls back, I use that dictionary to get the reference to my user control and set the data object. But this feels like a hack, what is the purpose of the GirdView Child Tables then if I cannot bind to them? Are those only useful if the Hierarchy Child Template has a GridView in it?
-OmarV
Hi Omar,
As far as it works , your approach seems acceptable to me .
About the child table definitions - So far their main purpose is to support standard hierarchy and nod so complicated scenarios.
Since I found your request absolutely reasonable , i have talked to the team. We have decided to improve the hierarchy API in order to ease the completion of scenarios like yours. This has been logged in our backlog and prioritized. This means it will appear in a future release of the RadGridView.
Thank you for the productive feedback. I have updated your Telerik points.
Kind regards,
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Thanks in advance,
Row Details is just another option and indeed can be used in such scenarios. If you want also expand/collapse column for Row Details similar to traditinal hierarchy please visit this blog post for more info:
http://blogs.telerik.com/blogs/posts/09-07-30/how_to_display_hierarchical_data_with_row_details_radgridview_for_silverlight.aspx
Sincerely yours,
Vlad
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
The RowDetails equivalent of OnExpandedRowStateChanged is called RowDetailsVisibilityChanged. This event is fired when row details are shown or hidden.
You can have full control over each individual GridViewRow through its DetailsVisibility property. Actually, in my blog post the toggle button in the leftmost column uses this property to show / hide row details, but you can do it programmatically from anywhere since the DetailsVisibility property is public.
Changing this property will result in the above mentioned RowDetailsVisibilityChanged event being fired for the grid. In the EventArgs of the event you will have the GridViewRow for which the details have been shown or hidden. To check whether they were shown or hidden you can read the e.Row.DetailsProvider.DetailsVisibility property.
I have prepared a small skeleton project that demonstrates all of the above.
Have in mind that I am using the latest internal build and you will need to upgrade if you want to have the RowDetailsVisibilityChanged event.
Kind regards,
Ross
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
There is a way, but it is not very easy. You will have to redefine the GridViewExpandableRow template and remove the plus sign. To learn how to style a row with blend, please see this help topic. The topic is about GridViewRow and GridViewNewRow, but the general approach is the same for all elements.
All the best,
Ross
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
