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

How do I create a hierarchary on a column instead of a data row in a GridView

7 Answers 76 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Jay
Top achievements
Rank 1
Jay asked on 19 Aug 2019, 03:42 PM
The data source for my main GridView object is a list of a custom object, which in turn contains child objects, and I want to be able to create a hierarchy grid that allows the user to drill into these child objects. I understand how to create the hierarchy if the entire row is a child record, but not how to accomplish this when a cell is the child record.

Example of my custom object is below.
public class Claim
{
    public Claim();
 
    //
    // Summary:
    //     Provider billing for services
    public Provider BillingProvider { get; set; }
    //
    // Summary:
    //     Claimant
    public Claimant Claimant { get; set; }
    //
    // Summary:
    //     Claim number
    public string ClaimNumber { get; set; }
    //
    // Summary:
    //     Member
    public Member Member { get; set; }
    //
    // Summary:
    //     Policy
    public Policy Policy { get; set; }
    //
    // Summary:
    //     Process date
    public DateTime ProcessDate { get; set; }
    //
    // Summary:
    //     Date claim was received
    public DateTime ReceiveDate { get; set; }
    //
    // Summary:
    //     Provider rendering services
    public Provider RenderingProvider { get; set; }
    //
    // Summary:
    //     List of services provided
    public List<Service> ServiceList { get; set; }
    //
    // Summary:
    //     Address where services were provided
    public Address ServiceLocation { get; set; }
    //
    // Summary:
    //     Worksheet / bill number
    public int Worksheet { get; set; }
}
//
// Summary:
//     Member
public class Member : Person
{
    public Member();
 
    //
    // Summary:
    //     Effective date
    public DateTime EffectiveDate { get; set; }
    //
    // Summary:
    //     Member ID
    public string MemberId { get; set; }
    //
    // Summary:
    //     Member's coverage policy
    public Policy Policy { get; set; }
    //
    // Summary:
    //     Termination date
    public DateTime TerminationDate { get; set; }
}
//
// Summary:
//     Person
public class Person
{
    public Person();
 
    //
    // Summary:
    //     Contact address
    public Address Address { get; set; }
    //
    // Summary:
    //     Date of birth
    public DateTime Dob { get; set; }
    //
    // Summary:
    //     First name
    public string FirstName { get; set; }
    //
    // Summary:
    //     Gender
    public string Gender { get; set; }
    //
    // Summary:
    //     Last name
    public string LastName { get; set; }
    //
    // Summary:
    //     Middle name
    public string MiddleName { get; set; }
    //
    // Summary:
    //     Social security number
    public string Ssn { get; set; }
}

7 Answers, 1 is accepted

Sort by
0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 20 Aug 2019, 07:28 AM
Hello, Jay, 

In order to generate a hierarchy in RadGridView from a nested list of records in the main object of the DataSource, I would recommend you to have a look at the following KB article. It provides the possible approaches that you can follow: https://docs.telerik.com/devtools/winforms/knowledge-base/gridview-build-hierarchy-from-a-nested-list

I hope this information helps. If you need any further assistance please don't hesitate to contact me. 

Regards,
Dess | Tech Support Engineer, Sr.
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
Jay
Top achievements
Rank 1
answered on 20 Aug 2019, 12:09 PM
Your response moves me in the right direction, but does not quite get me to the destination that I am seeking. I want to actually embed the sub-grid within the grid cell that contains the master record such that I have a column of sub-grids instead of a stack of sub-grids underneath the master row. I want a single cell to contain the complete entity that the cell represents instead of having to drill-down/expand to a new table to represent the entity.
0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 21 Aug 2019, 06:55 AM
Hello, Jay, 

By design, RadGridView offers two types of hierarchy:

- Self-reference hierarchy: In the cases when the hierarchical data is build from one type of items you can use a self-referencing RadGridView to display the data. This modes gives you all the functionality a TreeList control would provide, with a lot more.



- Master-Detail hierarchy: In this case RadGridView has as many levels as you need where each level represents a different schema containing the respective columns. Each level is a separate template.



It seems that the Self-reference hierarchy is close to the design you need. However, it requires identical records as type which share the same columns. 

An alternative approach that I can suggest is to have a look at RadTreeView which may be suitable for your case. It is possible to extend the default design by creating custom nodes

Feel free to use this approach which suits your requirements best.

Should you have further questions please let me know.

Regards,
Dess | Tech Support Engineer, Sr.
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
Jay
Top achievements
Rank 1
answered on 21 Aug 2019, 11:49 AM

Maybe I need to look at a different component in the DevCraft UI Suite then, as I am trying to get something similar to the attached image.

Thank you for your assistance.

0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 21 Aug 2019, 12:07 PM
Hello, Jay,  

The provided sample screenshot is greatly appreciated. In order to get a nested grid inside a cell of the main RadGridView, I would recommend you to use a GridViewMultiComboBoxColumn. It uses a RadMultiColumnComboBoxElement as an editor. It is just necessary to set the DataSource, DisplayMember and ValueMember properties of the column. Additional information how to setup the column is available in the following help article: https://docs.telerik.com/devtools/winforms/controls/gridview/columns/column-types/gridviewmulticomboboxcolumn

Could you please give it a try and see whether it fits your scenario?

I am looking forward to your reply.

Regards,
Dess | Tech Support Engineer, Sr.
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
Jay
Top achievements
Rank 1
answered on 21 Aug 2019, 01:13 PM

Dess,

I looked at the link that you supplied and determined that will not meet my needs, as I am not showing different selection options for a single value, but an entire record.

I am trying to display data in a visual manner in the same way that someone would drill through XML nodes in that a single cell in the RadGridView can contain an entire record. Think of a row in the grid that represents a book, with columns for title, published year, author, publisher. The author cell, instead of being a text box with the author's name, is a record that contains cells for first name, last name, primary language, etc.

I am starting to lean towards the fact that I will have to "flatten" my data, which just doesn't present as nice as being able to nest details inside of a parent record.

0
Accepted
Dess | Tech Support Engineer, Principal
Telerik team
answered on 22 Aug 2019, 01:17 PM
Hello, Jay,  

RadGridView offers the functionality for creating custom cell elements. Thus, you can construct the desired layout for the certain cells. A sample approach is demonstrated in the following help article: https://docs.telerik.com/devtools/winforms/controls/gridview/cells/creating-custom-cells

Note that you can use a RadHostItem in the custom cell element and host any control that you need to display the author's information, e.g. RadPropertyGrid. However, note that hosting controls in the grid cells is heavy and may slow down the scrolling and will cause visual glitches as they do not support clipping. A better option would be using custom editors. Thus, you can construct the desired editor and activate it for the respective cell. 

However, I have prepared a sample project for your reference which result is illustrated in the below screenshot:



Note that this is just a sample approach and it may not cover all possible cases. Feel free to modify it in a way which suits your requirements best.

I hope this information helps. If you need any further assistance please don't hesitate to contact me. 

Regards,
Dess | Tech Support Engineer, Sr.
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
GridView
Asked by
Jay
Top achievements
Rank 1
Answers by
Dess | Tech Support Engineer, Principal
Telerik team
Jay
Top achievements
Rank 1
Share this question
or