Master-Detail (Expandable Rows)

3 posts, 0 answers
  1. DoomerDGR8
    DoomerDGR8 avatar
    133 posts
    Member since:
    Aug 2010

    Posted 13 Jan 2011 Link to this post

    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. DoomerDGR8
    DoomerDGR8 avatar
    133 posts
    Member since:
    Aug 2010

    Posted 14 Jan 2011 Link to this post

    Any ideas? Still can't figure out the query...
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Julian Benkov
    Admin
    Julian Benkov avatar
    1135 posts

    Posted 18 Jan 2011 Link to this post

    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.
Back to Top