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

Multiple relations with same parent

8 Answers 185 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Peter Luth
Top achievements
Rank 1
Peter Luth asked on 03 Jun 2008, 02:19 PM
Hello,

I am trying to create a RadGridView which have multiple GridViewTemplates as hierarchical data. It works for my first relation using ParentColumnNames and ChildColumnNames, however, when adding my second relation, it does not work.

A small attached code sample is here, thanks:
    public class Client 
    { 
        public int ID { getset; } 
        public string Name { getset; } 
 
        public Client(int id, string name) 
        { 
            ID = id; 
            Name = name; 
        } 
    } 
 
    public class Order 
    { 
        public int ID { getset; } 
        public int ClientID { getset; } 
        public int Quantity { getset; } 
 
        public Order(int id, int clientid, int quantity) 
        { 
            ID = id; 
            ClientID = clientid; 
            Quantity = quantity; 
        } 
    } 
 
    public class OrderPrices 
    { 
        public int ID { getset; } 
        public int ClientID { getset; } 
        public double Price { getset; } 
 
        public OrderPrices(int id, int clientid, double price) 
        { 
            ID = id; 
            ClientID = clientid; 
            Price = price; 
        } 
    } 
 
        private void Form1_Load(object sender, EventArgs e) 
        { 
            radGridView1.AutoGenerateHierarchyFromDataSet = false
 
            ordersTemplate = new GridViewTemplate(this.radGridView1); 
            radGridView1.MasterGridViewTemplate.ChildGridViewTemplates.Add(ordersTemplate); 
 
            GridViewRelation relation1 = new GridViewRelation(this.radGridView1.MasterGridViewTemplate); 
            relation1.RelationName = "Clients Orders1"
            relation1.ParentColumnNames.Add("ID"); 
            relation1.ChildColumnNames.Add("ClientID"); 
 
            relation1.ChildTemplate = ordersTemplate; 
            radGridView1.Relations.Add(relation1); 
 
            orderPricesTemplate = new GridViewTemplate(radGridView1); 
            radGridView1.MasterGridViewTemplate.ChildGridViewTemplates.Add(orderPricesTemplate); 
 
            GridViewRelation relation2 = new GridViewRelation(radGridView1.MasterGridViewTemplate); 
            relation2.RelationName = "Clients Order Prices"
            relation2.ParentColumnNames.Add("ID"); 
            relation2.ChildColumnNames.Add("ClientID"); 
 
            relation2.ChildTemplate = orderPricesTemplate; 
            radGridView1.Relations.Add(relation2); 
 
            LoadData(); 
        } 
 
        private void LoadData() 
        { 
            BindingList<Client> clients = new BindingList<Client> 
                  { 
                      new Client(1, "John Smith"), 
                      new Client(2, "Peter Jackson"), 
                      new Client(3, "Samuel Dell"), 
                      new Client(4, "Test"
                  }; 
 
            BindingList<Order> orders = new BindingList<Order> 
                { 
                    new Order(1, 1, 2), 
                    new Order(1, 1, 1), 
                    new Order(1, 2, 10), 
                    new Order(1, 3, 43) 
                }; 
 
            BindingList<OrderPrices> orderprices = new BindingList<OrderPrices> 
               { 
                   new OrderPrices(1, 4, 1.50), 
                   new OrderPrices(1, 4, 9.99), 
                   new OrderPrices(1, 1, 10.11), 
                   new OrderPrices(1, 2, 43.42) 
               }; 
 
 
            orderPricesTemplate.DataSource = orderprices; 
            ordersTemplate.DataSource = orders; 
 
            radGridView1.DataSource = clients; 
        } 

8 Answers, 1 is accepted

Sort by
0
Accepted
Nikolay
Telerik team
answered on 06 Jun 2008, 11:33 AM
Hello Martin Bo,

Currently, RadGridView supports displaying only one template in this scenario. We will add the desired feature in one of our upcoming releases.

Feel free to contact me again, if you have further questions.

Kind regards,
Nikolay
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Peter Luth
Top achievements
Rank 1
answered on 06 Jun 2008, 11:45 AM
Thank you for your response.

It is sad to hear that it's currently not implemented, since it is supported by your ASP .NET RadGrid component, for which we are also using for the same functionality.

I am looking forward to the release with this functionality added.

Thanks.
0
Lecoq
Top achievements
Rank 1
answered on 22 Aug 2008, 01:26 PM
How your radgridview gonna support more than one template??? And why it's working in your exemple but you say that is not working right now?!?!?
0
Nikolay
Telerik team
answered on 22 Aug 2008, 02:12 PM
Hello Lecoq,

Actually, support of multiple templates in one level of hierarchy is already implemented logically, through the API. However, there is no visual representation of having several templates in one level, yet.
Therefore, I am a bit surprised to find that you see a working example of this feature. Could you please share with me which example you are concerning?

Greetings, Nikolay
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Lecoq
Top achievements
Rank 1
answered on 22 Aug 2008, 02:33 PM
in the demo of the radcontrols for the windows forms examples, see the gridview hierarchy example, you have 2 drill down, so you use 2 templates to make your 2 relations between your 3 tables. So why the example works and the object not?!?!?!?!?
0
Nikolay
Telerik team
answered on 25 Aug 2008, 11:46 AM
Hello Lecoq,

Regarding the Hierarchy example, you have 3 levels of hierarchy with 3 templates - one template for each of the levels. The feature we are discussing here is the possibility to have 2 templates in just one level of hierarchy. As I mentioned, currently this is not visually implemented, but it will be addressed in one of our next versions.

Sincerely yours,
Nikolay
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Lecoq
Top achievements
Rank 1
answered on 25 Aug 2008, 12:55 PM

Dim ds As DataSet
ds = GetMasterList()
grid.GridElement.BeginUpdate()
grid.DataMember =
"Poste"
grid.DataSource = ds
grid.AutoGenerateHierarchyFromDataSet =
True
grid.Rows(3).IsExpanded = True
grid.Columns("Cle").IsVisible = False

Dim template As GridViewTemplate = New GridViewTemplate(grid)
template.DataSource = child
grid.MasterGridViewTemplate.ChildGridViewTemplates.Add(template)
Dim relation As GridViewRelation = New GridViewRelation(grid.MasterGridViewTemplate)
relation.RelationName =
"Poste"
relation.ParentColumnNames.Add("cle")
relation.ChildColumnNames.Add(
"cle")
relation.ChildTemplate = template
grid.Relations.Add(relation)

Dim template2 As GridViewTemplate = New GridViewTemplate(grid)
template2.DataSource = child2
template.ChildGridViewTemplates.Add(template2)
Dim relation2 As GridViewRelation = New GridViewRelation(template)
relation2.RelationName =
"Journal"
relation2.ParentColumnNames.Add("Jrnl_Id")
relation2.ChildColumnNames.Add(
"Jrnl_Id")
relation2.ChildTemplate = template2
grid.Relations.Add(relation2)
grid.DataSource = ds.Tables(0)

I have the error message: "Sort string contains a property that is not in the IBindingList" at the line "grid.Relations.Add(relation2)"

Can you help me?

0
Nikolay
Telerik team
answered on 28 Aug 2008, 02:40 PM
Hi Lecoq,

When manually creating the hierarchy structure of RadGridView, as in your case, there is no need to set the AutoGenerateHierarchyFromDataSet property to True. Rather, it should be set to False. In addition, please make sure that you are naming your columns correctly.

If you continue to experience this issue, please open a new support ticket and send me a sample project which demonstrates it. This will allow me to further analyze your case and to give you more accurate assistance.
 

All the best,
Nikolay
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
GridView
Asked by
Peter Luth
Top achievements
Rank 1
Answers by
Nikolay
Telerik team
Peter Luth
Top achievements
Rank 1
Lecoq
Top achievements
Rank 1
Share this question
or