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

Master-Detail (Expandable Rows)

2 Answers 172 Views
GridView
This is a migrated thread and some comments may be shown as answers.
DoomerDGR8
Top achievements
Rank 2
Iron
Iron
Iron
DoomerDGR8 asked on 13 Jan 2011, 12:45 PM
I'm attempting to bind a Grid (programmatic-approach) through LINQ. Here is the scenario: I have a table of clients. Every client has branches and coordinators. They have more collections but I don't want to expose them. I want to show the clients in a grid with different filtering criteria. For every client, the row expands to two tabs: Branches and Coordinators

The sub rows in the Branches View and Coordinator View must NOT be further expandable.

I want to select the columns to be shown in the Branches and Coordinators Details View.

I have tried these two approached with no success:

RadGridViewSearch.DataSource = from pharms in DbContext.Pharmacies
                 where pharms.IsActive && pharms.Branches.Count > 0
                 orderby pharms.Name
                 select new {
                   pharms.OID,
                   pharms.Name,
                   pharms.PhoneNumber,
                   AddressInfo = String.Format("{0} {1} {2} {3}",
                         pharms.Contact.Addresses.FirstOrDefault().HouseNumber ??
                         String.Empty,
                         pharms.Contact.Addresses.FirstOrDefault().Street ??
                         String.Empty,
                         pharms.Contact.Addresses.FirstOrDefault().Area ??
                         String.Empty,
                         pharms.Contact.Addresses.FirstOrDefault().PostCode ??
                         String.Empty),
                   CityName = pharms.Contact.Addresses.FirstOrDefault().City.Name,
                   pharms.Branches,
                   pharms.PharmacyCoordinators
                 };
 
RadGridViewSearch.DataSource = from pharms in DbContext.Pharmacies
                 from branches in pharms.Branches.DefaultIfEmpty()
                 from coords in pharms.PharmacyCoordinators.DefaultIfEmpty()
                 where pharms.IsActive && pharms.Branches.Count > 0 && pharms.PharmacyCoordinators.Count > 0
                 orderby pharms.Name
                 select new {
                   ClientOID = pharms.OID,
                   ClientName = pharms.Name,
                   ClientPhoneNumber = pharms.PhoneNumber,
                   ClientAddressInfo = string.Format("{0} {1} {2} {3}",
                         pharms.Contact.Addresses.FirstOrDefault().HouseNumber ??
                         string.Empty,
                         pharms.Contact.Addresses.FirstOrDefault().Street ??
                         string.Empty,
                         pharms.Contact.Addresses.FirstOrDefault().Area ??
                         string.Empty,
                         pharms.Contact.Addresses.FirstOrDefault().PostCode ??
                         string.Empty),
                   ClientCityName = pharms.Contact.Addresses.FirstOrDefault().City.Name,
                   BranchOID = branches.OID,
                   BranchName = branches.BranchNumber,
                   BranchPhoneNumber = branches.PhoneNumber,
                   BranchAddressInfo = String.Format("{0} {1} {2} {3}",
                          branches.Contact.Addresses.FirstOrDefault().HouseNumber ??
                          String.Empty,
                          branches.Contact.Addresses.FirstOrDefault().Street ??
                          String.Empty,
                          branches.Contact.Addresses.FirstOrDefault().Area ??
                          String.Empty,
                          branches.Contact.Addresses.FirstOrDefault().PostCode ??
                          String.Empty),
                   BranchCityName = branches.Contact.Addresses.FirstOrDefault().City.Name,
                   CoordinatorOID = coords.OID,
                   CoordinatorName = coords.FirstName + " " + coords.LastName,
                   CoordinatorCell = coords.MobileNumber,
                   CoordinatorEmail = coords.Email
                 };

The first one produces the desired result in short time but the results are uncontrolled. I cant prevent deep-drilling, Tabs names, and Columns. The second one produces liners results and hence that fails as well. And the second one takes massive time...

Can anyone guide on this?

Objective: Create Master details grid with full control of all Column Headers (Master + Detail), All details Tabs Names

2 Answers, 1 is accepted

Sort by
0
DoomerDGR8
Top achievements
Rank 2
Iron
Iron
Iron
answered on 14 Jan 2011, 11:42 AM
Any ideas? Still can't figure out the query...
0
Julian Benkov
Telerik team
answered on 18 Jan 2011, 09:52 AM
Hello Hassan,

Please refer to this article which concerns your scenario. In your case you can generate the hierarchy manually.

All the best,

Julian Benkov
the Telerik team

 

Q3’10 SP1 of RadControls for WinForms is available for download; also available is the Q1'11 Roadmap for Telerik Windows Forms controls.
Tags
GridView
Asked by
DoomerDGR8
Top achievements
Rank 2
Iron
Iron
Iron
Answers by
DoomerDGR8
Top achievements
Rank 2
Iron
Iron
Iron
Julian Benkov
Telerik team
Share this question
or