DataGridView - Parent Child rows

DataGridView - Parent Child rows

Old forum URL: forums.lhotka.net/forums/t/1210.aspx


gajit posted on Wednesday, September 13, 2006

Hi guys,

I've searched the forums and can't find any information on this, but I suspect its a common enough question.. (csla 2.x, vb.net 2005)

I have a datagridview, in which I would like to display a view of parent-child data. In essence, customers and orders - I need some "drill-down" capability in this app. .. Now I know that you can do this using datatables/views etc, but I'm at a loss as to how I do this with csla-businessclass data.

I have defined my business classes and I can happily display the parent rows, but there appears to be no inner-workings in the datagridview that recognize the childclasses of businessbase class.

The views need only be readonly.

Do I have to somehow create a dataview/table from my csla-objects and build relationships? If so, any pointers on how I do that?

Thanks in advance.

g.

 

 

 

 

 

 

 

 

 

 

RockfordLhotka replied on Wednesday, September 13, 2006

If you set up your objects like:

Parent
 -> ChildList
  -> Child
    -> GrandChildList
      -> GrandChild

and then use data binding by putting two grids on your form (one for ChildList, one for GrandChildList), data binding should automatically handle the drill-down for you. In other words, as you select a Child in the first grid, the appropriate GrandChildList should be displayed in the second grid.

The reason this works is that the bindingsource objects created by data binding automatically understand the parent-child relationships between the objects. To get this to work (at least easily) you should drag-and-drop the classes onto your form from the Data Sources window - Visual Studio will do all the hard work.

gajit replied on Wednesday, September 13, 2006

Hi Rocky,

Thanks for the reply.

I probably wasn't too clear in my initial (rushed) post.

What you describe I have achieved, but the behaviour I am trying to reproduce is within a single datagrid/datagridview.

With datasets/views, et al, in VS.net came this cool ability to create relations between a parent dataset and a child dataset and have them handled within the single grid control. The grid automatically displays the 'expando' icon, which when clicked 'drills-down' and displays the child rows directly beneath the parent row.

As the grid is probably geared toward those relations being in place (feel free to prove me wrong :) ) - is there a 'simple' way to build a generic dataview type from say a CSLA sortedbindinglist?

Thanks again,

Graham

 

 

 

 

 

 

 

 

RockfordLhotka replied on Thursday, September 14, 2006

That was true in .NET 1.x with the old grid. The new DataGridView is not hierarchical and can't do what you want.
 
You'll either have to use the old grid (yuck), or get a 3rd party grid that supports the concept.
 
Either way, it should work with collections of objects - they have implicit relationships that can be navigated.
 
Rocky


From: gajit [mailto:cslanet@lhotka.net]
Sent: Wednesday, September 13, 2006 11:54 PM
To: rocky@lhotka.net
Subject: Re: [CSLA .NET] DataGridView - Parent Child rows

Hi Rocky,

Thanks for the reply.

I probably wasn't too clear in my initial (rushed) post.

What you describe I have achieved, but the behaviour I am trying to reproduce is within a single datagrid/datagridview.

With datasets/views, et al, in VS.net came this cool ability to create relations between a parent dataset and a child dataset and have them handled within the single grid control. The grid automatically displays the 'expando' icon, which when clicked 'drills-down' and displays the child rows directly beneath the parent row.

As the grid is probably geared toward those relations being in place (feel free to prove me wrong :) ) - is there a 'simple' way to build a generic dataview type from say a CSLA sortedbindinglist?

Thanks again,

Graham

 

 

 

 

 

 

 

 




gajit replied on Thursday, September 14, 2006

Well, I learn something new everyday - I was unaware of this. There go my promises of a new fan-dangled-bells-and-whistles laden module... :)

Thanks for your help Rocky.

 

 

tetranz replied on Thursday, September 14, 2006

I know this is not the answer you were hoping for but FWIW, the Janus grid does a very nice job with hierarchical data. Its about $300 for one developer. Royalty free distribution.

Ross

gajit replied on Thursday, September 14, 2006

Hi Ross,

 

Thanks.

Have you successfuly used this with CSLA hierarchy?

Graham

 

 

tetranz replied on Thursday, September 14, 2006

Re the Janus grid

gajit:

Have you successfuly used this with CSLA hierarchy?

Yes and it works well. You only need one bindingSource. You bind the root collection to that and, if you ask it to, the grid will discover properties that are collections. The design time support is pretty good.

I was an early user of their version 3 grid and found a few minor problems that they fixed very quickly.

I think there is a time limited free trial at www.janusys.com

Ross

Copyright (c) Marimer LLC