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

Copying RowFormatting in GridView with Hierarchy

2 Answers 26 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Stefan
Top achievements
Rank 1
Stefan asked on 09 Dec 2010, 04:57 PM
Hello,

I'm using the hierarchical gridview with an object-relational datasource (programatically).
I'm displaying a list of order Items which have the property "ParentOrderItem".
Every item with a parent order item is displayed as a child row. Everything works fine.

What I want to do is copying the formatting of the gridview (done via Property Bilder - saying which columns to be shown, which header texts, ...) to the format of the child rows, since they alway show the same entities. This would help me doing the same work only once.

Here is the code where I set up my hierarchy:
//orderItemsgrid.DataSource is "theOrder.SD_Order_Items"

GridViewTemplate template = new GridViewTemplate();
template.DataSource = theOrder.SD_OrderItems;
orderItems_grid.MasterTemplate.Templates.Add(template);
 
GridViewRelation relation = new GridViewRelation(orderItems_grid.MasterTemplate);
relation.ChildTemplate = template;
relation.RelationName = "OrderItemOrderItem";
relation.ParentColumnNames.Add("OrderItemID");
relation.ChildColumnNames.Add("ParentOrderItem");
orderItems_grid.Relations.Add(relation);

Thanks for any help on this matter.

Stefan

2 Answers, 1 is accepted

Sort by
0
Accepted
Emanuel Varga
Top achievements
Rank 1
answered on 11 Dec 2010, 09:48 AM
Hello Stefan,

Might i suggest a different way of doing this?

Just copy all of your formatting code from the designer.cs and add it either to the DataBindingComplete event, for all the templates and threat each template there, or, when creating the templates, if you are also creating them from the property builder make all the changes there also.

Hope this helps, if you have any other questions or comments, please let me know,

Best Regards,
Emanuel Varga

Telerik WinForms MVP
0
Stefan
Top achievements
Rank 1
answered on 13 Dec 2010, 03:49 PM
Hi Emanuel,

thanks for your suggestion, but this way does not work for me.
I use many different entities, therefore I will have many grids and probably more than one hierarchical view.
I really need a solution where I can setup the "Parent Grid" in the Property Builder and copy these settings on runtime.
Any other idea?

Stefan
Tags
GridView
Asked by
Stefan
Top achievements
Rank 1
Answers by
Emanuel Varga
Top achievements
Rank 1
Stefan
Top achievements
Rank 1
Share this question
or