I need to create something like a master/details view in my RadGridView, but every detail can have its own details as well (that's why I need more that one level of hierarchies).
Thanks a lot.
8 Answers, 1 is accepted
radGridView1.DataSource = nwindDataSet.Suppliers; |
GridViewTemplate template = new GridViewTemplate(); |
template.DataSource = nwindDataSet.Products; |
radGridView1.MasterGridViewTemplate.ChildGridViewTemplates.Add(template); |
GridViewRelation relation = new |
GridViewRelation(radGridView1.MasterGridViewTemplate); |
relation.ChildTemplate = template; |
relation.RelationName = "SuppliersProducts"; |
relation.ParentColumnNames.Add("SupplierID"); |
relation.ChildColumnNames.Add("SupplierID"); |
radGridView1.Relations.Add(relation); |
Something like that would be excatly what I need, because basically I got a DataSet with DataTables that have DataRelations between them, can something like that apply to WPF? What other approach can you suggest?
Thanks again.
I believe this forum thread will be helpful in your case, especially as you can download a sample project. It is for Silverlight, but you can easily implement it to WPF.
If you have any further questions, please do not hesitate to get back to us.
Maya
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.
I have my original GridView bound to a DataSet's first table, called "Years". Table "Years" has a column (amongst others) called "Year", which is the column I'm trying to create the relation from. The DataSet's also got another table called "Semesters", which also has a column called "Year", and it also has a column called "Semester" and some other more. Finally, I got a third table called "Months", which has, amongst others, two columns, "Year" and "Semester".
What I need to do is to let the user see all the columns from table Years first, and then create a hierarchy for each year's semester, and then another hierarchy for each semester's month.
By looking at the code provided in th thread you suggested me, I notice that you created a Relation and added it to the grid, but the example shows a relation to the same data. The thing I can't figure out is how to bind the inside grids to the respective DataTable.
Thanks a lot.
If I understand correctly, you want to create three-layer hierarchy - the Parent is the "Year" and for every row "Semester" comes out as a Child. And in the end "Month" appears as a child of "Semester".
There are a couple of ways that you can create multi-level hierarchy.
Firstly, you may define them in xaml. In the parent grid you need to define its ChildTableDefinitions and HierarchyChildTemplate. Furthermore, in order to create the second level of hierarchy, you have to define its ChildTableDefinitions and HierarchyChildTemplate. You may use as a reference this blog post, which probably does not cover exactly your case, but it will give the basic idea of creating three-level hierarchy.
Furthermore, you may use the Property Relation of the grid and to specify the property that connects the levels of the hierarchy. You may take a look at this forum thread.
Another possible solution is to define the hierarchy and the property Relation in the code-behind.
I am sending you a sample project that demonstrates some of those cases.
However, you can always use as a reference our online documentation.
Maya
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.
Relations are defined with a PropertyRelation object, that takes the (only one) column you want to relate the parent and child table. But what I actually need to do requieres the relation to have more than one column. Check this example of what my DataSet would look like:
Table YEARS:
Year CompanyName ManagerName
2010 AAAAA MMMMM
2010 BBBBB NNNNNN
Table SEMESTERS:
Year Semester CompanyName ManagerName
2010 1 AAAAA MMMMM
2010 2 AAAAA MMMMM
2010 1 BBBBB NNNNNN
2010 2 BBBBB NNNNNN
Table MONTHS:
Year Semester Month CompanyName ManagerName
2010 1 Apr AAAAA MMMMM
2010 1 May AAAAA MMMMM
2010 2 Aug AAAAA MMMMM
2010 2 Nov AAAAA MMMMM
2010 1 Feb BBBBB NNNNNN
2010 2 Oct BBBBB NNNNNN
2010 2 Nov BBBBB NNNNNN
What the user needs is to be able to see data by year, and then be able to "zoom in" the details of each semester, and again of each month (actually I got trimesters, weeks and days as well, but the general idea is the same). One problem is, for instance, that the relation between table YEARS and table SEMESTERS isn't by the Year column only, but by CompanyName and ManagerName columns as well, because obvioulsy for year 2010 I got two records, one for each company.
The other problem is that the user wants to be able to select any period as his starting point. So he may choose to see all the way from the years down, or only from the semesters down, or only the months.
I'm going to have to talk to my user about it, because I loosing a lot of time trying to figure this out, and I haven't been able to get anywhere.
Thanks anyway for your great help, as always.
When creating complicated relations in a hierarchy you may try to use View Models and to bind every one of them to the desired state of the application.
I hope that helps.
Maya
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.
I checked out the earlier versions of our components and it seems that the hierarchy of RadGridView is available for the 2010.2.0924 version. This can also be observed in the sample application provided by my colleague, as it references even older binaries. Can you please take a look at it?
Regards,
Stefan X1
Progress Telerik