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

Grid with a hierarchical foreingkey

3 Answers 52 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Kevin
Top achievements
Rank 1
Iron
Kevin asked on 25 Aug 2015, 11:21 AM

Hi,

       I have 2 tables

             Table1 : ID,Table2ID

              Table2 : ID, Description

Table1 as a 1 to many relationship with Table2

Table2 as a 0..1 to many relationship with Table2

I would like to show Table1 in a grid and have a treeview to display the Table2 during Create and Update.

Can someone help me to achieve this?

 

regards

3 Answers, 1 is accepted

Sort by
0
eo
Top achievements
Rank 1
answered on 25 Aug 2015, 07:16 PM

Hello Kevin,

I wouldn't recommend trying to put treeviews inside of a grid because that is not its intended use. It sounds like using a hierarchical grid is the way to go in your case. Here's a Telerik demo that shows this functionality for ASP.NET MVC.

Hope that helps!

0
Kevin
Top achievements
Rank 1
Iron
answered on 26 Aug 2015, 11:04 AM

Hi eo,

 

    I am not sure this will fix my issue that I need to show during edition or creation of a new Table1 record the hierarchy of Table2.

    To give a more practical touch to this post here the class and database.

Table 1 : BypassEquipmentLog

 

public class BypassEquipmentLog
{
    [ScaffoldColumn(false)]
    public int Id { get; set; }
 
    //[UIHint("ApproverEditor")]
    public Approver Approver { get; set; }
 
    //[UIHint("ManagerEditor")]
    public Manager Manager { get; set; }
 
    //[UIHint("WorkerEditor")]
    public Worker Worker { get; set; }
 
    public Asset Asset { get; set; }
 
    public string Description { get; set; }
 
    public string Reason { get; set; }
 
    public DateTime Date { get; set; }
 
    public DateTime Timestamp { get; set; }
}

Table2 : Asset

public class Asset
    {
        public long Id { get; set; }
        public string Description { get; set; }
        public bool HasChildren { get; set; }
    }

Database see attach.

 

0
Boyan Dimitrov
Telerik team
answered on 27 Aug 2015, 01:46 PM

Hello Kevin,

 

Please find an Grid Popup Editing Navigation Property Collection with nested Grid project that demonstrates a how to edit a nested collection with another Grid and perform single request to update both the parent and the child grids with a single request.

 

Regards,
Boyan Dimitrov
Telerik
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 Feedback Portal and vote to affect the priority of the items
Tags
Grid
Asked by
Kevin
Top achievements
Rank 1
Iron
Answers by
eo
Top achievements
Rank 1
Kevin
Top achievements
Rank 1
Iron
Boyan Dimitrov
Telerik team
Share this question
or