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

Hierarchy/Grouping

1 Answer 115 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Chris May
Top achievements
Rank 1
Chris May asked on 16 Feb 2011, 06:02 PM
I'm trying to do something that seems simple, but I don't see any examples.  I'm wondering if it's possible.

I want to show a radgrid, where each row is grouping of many detail rows.  Then I want the user to be able to expand the row and see the detail rows.  Both the detail rows and the group rows should have the same columns.

So, picture a datasource like this:

UserId
UserName
InvoiceId
InvoiceAmount

We would want the grid to first show each row with (so:

UserName, Count(), Sum(InvoiceAmount)
For example:

BillJ, 3, $123
JohnM, 2, $323
SteveP, 4, $554

(But we want these in columns that are sortable, not as a comma separated string like the Group Header examples show)

and then when you expanded you would see rows like:

BillJ, 1, $100
BillJ, 1, $20
BillJ, 1, $3


I was hoping to do this with 1 datasource that contains the detail rows, and have the grid figure out the count and sum.

Is this not possible?  Do I have to follow the hierarchy example and use multiple datasources (one where I calculate the sums, counts in the data before binding, and another that has the detail rows)?

1 Answer, 1 is accepted

Sort by
0
Radoslav
Telerik team
answered on 22 Feb 2011, 08:54 AM
Hello Chris,

In order to achieve the desired functionality you need to use the hierarchical RadGrid. In this case you will have the parent rows and detail rows which have possibilities for sorting. I suggest you to use the hierarchical RadGrid with programmatic binding. Into the NeedDataSource event you could fetch the data about UserName, Count(), Sum(InvoiceAmount) and into DetailTableDataBind event you could get all records for the particular InvoiceId.

Please give it try and let me know if you experience any problems.

Greetings,
Radoslav
the Telerik team
Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
Tags
Grid
Asked by
Chris May
Top achievements
Rank 1
Answers by
Radoslav
Telerik team
Share this question
or