Customized GridView

1 Answer 55 Views
GridView
SoftwareBacci
Top achievements
Rank 1
SoftwareBacci asked on 11 Sep 2024, 03:57 PM

Hello,

In Telerik, I want to create a Grid that can differentiate between two objects and adjust the row accordingly. I understand that it's possible to customize row styles and templates, but the implementation I'm aiming for is a bit more complex, and I'm encountering some difficulties.

I have an object named "Program" with the following fields:

  • String Name;
  • String Id;
  • ObservableCollection<Operation> Operations;

Additionally, I have another object called "Operation" with the following fields:

  • string OpName;
  • string PartId;
  • int NumOfRepetitions;
  • etc.

The DataGrid takes a collection of 'Program' as input.

Here's what I want to achieve:

When a program contains a single operation, I want to group the program's and operation's data and display everything in a single, non-expandable row.

When a program contains multiple operations, I want to display a parent row with the program’s data and an expandable child grid that shows one operation per row with the relative data.

Is it possible to have different set of columns per each row and have only some rows which are expandable?

1 Answer, 1 is accepted

Sort by
0
Martin Ivanov
Telerik team
answered on 13 Sep 2024, 09:56 AM

Hello Gabriele,

I am not sure how exactly this various number of columns should look like, but I have attached a small example showing one way to get the desired effect. The example uses the row details feature of RadGridView. I hope it helps.

Regards,
Martin Ivanov
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.

SoftwareBacci
Top achievements
Rank 1
commented on 17 Sep 2024, 07:11 AM

Hello,

In the end, I solved it by using a combination of the 'expanded' and 'expandable' properties of the grid to determine whether a row could expand, and the 'hierarchyChildTemplate' to define the behavior of the expanded row.

Best,

Gabriele Baldi

Tags
GridView
Asked by
SoftwareBacci
Top achievements
Rank 1
Answers by
Martin Ivanov
Telerik team
Share this question
or