telerik winforms Expand/Collapse Grid List View

1 Answer 135 Views
GridView ListView
arbam
Top achievements
Rank 1
Iron
arbam asked on 05 Dec 2022, 04:09 PM
I drew an example in the picture.
The format of the data table read from db is shown on the left.
I want to show this on the grid and zoom in
Grouping does not show column information in the row that is being expanded/reduced, but I need information in all rows.
I want to express it like BOM.
I want to expand/reduce to a specific key flexibly according to the column of the table I'm reading, but I don't know what to do.

1 Answer, 1 is accepted

Sort by
1
Accepted
Dess | Tech Support Engineer, Principal
Telerik team
answered on 06 Dec 2022, 12:58 PM

Hi, Arbam,

According to the provided screenshot, it seems that you need to display a self-reference hierarchy in RadGridView. The following help article demonstrates a sample approach how to setup such kind of hierarchy in RadGridView: https://docs.telerik.com/devtools/winforms/controls/gridview/hierarchical-grid/self-referencing-hierarchy 

I have prepared a sample code snippet for your reference:  

            DataTable dt = new DataTable();
            dt.Columns.Add("ParentLevel", typeof(int));
            dt.Columns.Add("Level", typeof(int));
            dt.Columns.Add("column1", typeof(string));
            dt.Columns.Add("column2", typeof(string));
            dt.Columns.Add("column3", typeof(string));

            dt.Rows.Add(0, 1, "A", Guid.NewGuid().ToString(), Guid.NewGuid().ToString());
            dt.Rows.Add(1, 2, "B", Guid.NewGuid().ToString(), Guid.NewGuid().ToString());
            dt.Rows.Add(2, 3, "D", Guid.NewGuid().ToString(), Guid.NewGuid().ToString());
            dt.Rows.Add(1, 4, "C", Guid.NewGuid().ToString(), Guid.NewGuid().ToString()); 
            dt.Rows.Add(4, 6, "E", Guid.NewGuid().ToString(), Guid.NewGuid().ToString());
            dt.Rows.Add(6, 7, "F", Guid.NewGuid().ToString(), Guid.NewGuid().ToString());
            dt.Rows.Add(6, 8, "G", Guid.NewGuid().ToString(), Guid.NewGuid().ToString());

            this.radGridView1.Relations.AddSelfReference(this.radGridView1.MasterTemplate, "Level", "ParentLevel");
            this.radGridView1.DataSource = dt;
            this.radGridView1.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill;

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

Regards,
Dess | Tech Support Engineer, Principal
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Tags
GridView ListView
Asked by
arbam
Top achievements
Rank 1
Iron
Answers by
Dess | Tech Support Engineer, Principal
Telerik team
Share this question
or