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

Use First Look Example With Objects

7 Answers 118 Views
GridView
This is a migrated thread and some comments may be shown as answers.
StevenDale
Top achievements
Rank 2
StevenDale asked on 07 May 2009, 07:14 PM
Is it possible to use the first look example with objects?

I have a list of objectA and each object has 3 sublists. I want to display each sublist in a tab when the parent record is expanded, similar to the first look example provided.

I have managed a workaround by modifying the Custom Row Layout example and using an expander but it is not as clean as the First Look Example.

Thanks,

Billy Jacobs

7 Answers, 1 is accepted

Sort by
0
Vlad
Telerik team
answered on 08 May 2009, 06:40 AM
Hi Billy,

Indeed you can achieve the same with objects very easily. You need to use however PropertyRelation instead TableRelation  - please check this example for more info:
http://demos.telerik.com/wpf/?GridView/Hierarchy/PropertyHierarchy

All the best,
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.
0
StevenDale
Top achievements
Rank 2
answered on 11 May 2009, 05:43 PM
That worked, however, I have a follow up question. Is there an event that fires whenever you expand a heirarchy? What I mean by expand the heirarchy is when you click the expander arrow and open up the child records in the Grid.

Thanks,

Billy Jacobs
0
Vlad
Telerik team
answered on 12 May 2009, 07:37 AM
Hello Billy,

Please check this project for more info:
http://www.telerik.com/ClientsFiles/126889_silverlightgriddataservicehierarchy.zip

Greetings,
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.
0
StevenDale
Top achievements
Rank 2
answered on 15 May 2009, 02:29 PM

I have it working except for a few problems.

Here is what I am trying to accomplish and and what problems I am having.

I have ObservableCollection<ObjectA> which has 3 lists. List1, List2, and List3.

My parent RadGridView is bound to ObservableCollection<ObjectA>.

I have set up a PropertyRelation between List1. So the code would be.

 

GridViewTableDefinition

 

detailDefinition = new GridViewTableDefinition();

 

 

detailDefinition.Relation =

new PropertyRelation("List1");

 

 

 

this._physicalExamsGridView.TableDefinition.ChildTableDefinitions.Add(detailDefinition);

In my Child View I have a RadTabControl with 3 tabs. I want to display List1 on Tab1, List2 on Tab2 and List3 on Tab3. I want to display these lists in RadGridView controls and here is where my problem begins. If I use a regular ListView instead of a RadGridView I can subscribe to the Loaded Event for the ListView and within the Loaded event I can bind my ListView to any of the 3 Lists. This works correctly for each List on each Tab. However, if I try to do the exact same thing with RadGridView, it tries to bind all of the Grids to the objects that are defined in the GridViewTableDefinition and PropertyRelation defined above. It also autogenerates the columns which I have set to false and ignores the columns I have specified in XAML.

My loaded events look like the following and the code works correctly when using ListViews:

This WORKS For List1, List2 and List3 on appropriate tabs simultaneously when ListView is used.

ListView

 

_listListViewForList1 = (ListView)sender;

 

 

 

ObjectA objectOfTypeA = (ObjectA) (((ExpandableDataRecord)(((RecordManager)(((ListView)sender).DataContext)).MasterRecord)).Data);

 

 

_listListViewForList1.ItemsSource = objectOfTypeA.List1;

 

 

 

 

This DOES Not work with RadGridView EXCEPT for the Relation created above for List1. List2 and List3 give errors.

 

 

RadGridView _gridViewForList1 = (RadGridView)sender;

 

 

 

ObjectA objectOfTypeA = (ObjectA) (((ExpandableDataRecord)(((RecordManager)(((RadGridView)sender).DataContext)).MasterRecord)).Data);

 

 

_gridViewForList1.ItemsSource = objectOfTypeA.List;

 

 

 

 

 

 

Causes Error:

RadGridView _gridViewForList2 = (RadGridView)sender;

 

ObjectA objectOfTypeA = (ObjectA) (((ExpandableDataRecord)(((RecordManager)(((RadGridView)sender).DataContext)).MasterRecord)).Data);  

 

_gridViewForList2.ItemsSource = objectOfTypeA.List2;



Causes Error: 

 

 

RadGridView _gridViewForList3 = (RadGridView)sender;  

 

ObjectA objectOfTypeA = (ObjectA)  (((ExpandableDataRecord)(((RecordManager)(((RadGridView)sender).DataContext)).MasterRecord)).Data);  

 

 

_gridViewForList3.ItemsSource = objectOfTypeA.List3

;

 

 


To clarify. Lets use the definition above where my PropertyRelation is bound to List1. When my grid on Tab1 is opened and I bind the grid programatically to the items in List1 it works correctly except that it ignores my autogeneratecolumns=false. When I click on Tab2 and the Loaded event fires for Grid2 I get an error when I try to bind the grids ItemsSource to List2. It says that it cannot convert the items that are the type of objects in List1 to the type of objects in List2.

So, is there some way to remove the auto-binding that is hooked up between the parent RadGridView and the RadGridViews that are listed in the Hierarchical Child?


Also, if I create all 3 property relations, one for each list,  then I get 3 sub-sections when I expand the master record and I don't want that.

Thanks,

Billy Jacobs

 

0
Vlad
Telerik team
answered on 19 May 2009, 06:29 AM
Hi Billy,

Please check the attached project and let me know how it goes.

Regards,
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.
0
StevenDale
Top achievements
Rank 2
answered on 19 May 2009, 10:48 PM
It works except for one problem.

If I use the RadGridView_Loaded event to set the ItemsSource it works correctly. However, if I set the ItemsSource Binding in XAML in the RadGridView markup, then even though I have autogenerate columns set to false it autogenerates all of the columns and ignores the ones I have.

In my RadGridView markup I had:
 

<

 

telerik:RadGridView Foreground="Black" AutoGenerateColumns="False" DataContext="{Binding MasterRecord.Data.PatientProcedures}" Loaded="RadGridView_Loaded" ColumnsWidthMode="Fill" telerik:StyleManager.Theme="Office_Black">

 

 

 

<telerik:RadGridView.Columns>

 

 

 

<telerik:GridViewDataColumn HeaderText="Name" DataType="{x:Type System:String}" DataMemberBinding="{Binding Path=Procedures.FullDescription}" UniqueName="{x:Null}"/>

 

 

 

<telerik:GridViewDataColumn HeaderText="Procedure Note" DataMemberBinding="{Binding Path=ProcedureNote}" UniqueName="{x:Null}" />

 

 

 

<telerik:GridViewDataColumn HeaderText="Started" DataMemberBinding="{Binding Path=StartTime}" UniqueName="{x:Null}" />

 

 

 

<telerik:GridViewDataColumn HeaderText="Ended" DataMemberBinding="{Binding Path=EndTime}" UniqueName="{x:Null}" />

 

 

 

<telerik:GridViewDataColumn HeaderText="Comments" DataMemberBinding="{Binding Path=Comments}" UniqueName="{x:Null}" />

 

 

 

</telerik:RadGridView.Columns>

 

 

 

</telerik:RadGridView>

 



I am willing to use the loaded event if it is the only workaround.

Let me know and thanks very much for the solution.

Billy Jacobs
0
Accepted
Vlad
Telerik team
answered on 20 May 2009, 05:51 AM
Hi Billy,

You are right about the problem and indeed Loaded event is a temporary workaround. We will do our best to provide fix for this as soon as possible.

All the best,
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.
Tags
GridView
Asked by
StevenDale
Top achievements
Rank 2
Answers by
Vlad
Telerik team
StevenDale
Top achievements
Rank 2
Share this question
or