Simple question re janus grids...

Posts   
 
    
hplloyd
User
Posts: 191
Joined: 29-Oct-2004
# Posted on: 26-Apr-2005 09:43:20   

I am sure that this is obvious but I cant work it out....

I have 2 tables a parent table and a child table....

I fetch a collection of parent table entities and use a prefetch to also fetch the child table collection for each parent entity.

Now, I have a windows form with 2 janus grids ParentGrid and ChildGrid

I want the datasource of the parent grid to be the parent entity collection and the datasource of the child grid to be the prefetched child collection... Therefore as I scroll down the parent grid the child list updates - a faairly common requirement I assume.

If I store the fetch in a collection called myCollection then somehow I want to do

ParentGrid.DataSource = myCollection Childgrid.DataSource = myCollection.ChildCollection

How do I do this sort of thing....

Also, If the user changes the details of a child entity and I save that back to the databse.... does the child collection get updated automatically? Will the child collection also be updated with entites I add or remove (for a specific parent entity)

Many thanks for all your help.... I am nearly getting there with this firebird smart client app that I am building - my first proper chunky test of LLBL collections etc, and LLBL (together with the 3rd party manager classes slightly modified) has saved me tons of time and enabled me to (for the first time actually) build a "proper" business logic layer.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39933
Joined: 17-Aug-2003
# Posted on: 26-Apr-2005 12:32:30   

hplloyd wrote:

I am sure that this is obvious but I cant work it out....

I have 2 tables a parent table and a child table....

I fetch a collection of parent table entities and use a prefetch to also fetch the child table collection for each parent entity.

Now, I have a windows form with 2 janus grids ParentGrid and ChildGrid

I want the datasource of the parent grid to be the parent entity collection and the datasource of the child grid to be the prefetched child collection... Therefore as I scroll down the parent grid the child list updates - a faairly common requirement I assume.

If I store the fetch in a collection called myCollection then somehow I want to do

ParentGrid.DataSource = myCollection Childgrid.DataSource = myCollection.ChildCollection

No, you bind the SAME collection simple_smile ParentGrid.DataSource = myCollection Childgrid.DataSource = myCollection

Then, you define in the Childgrid, the DataMember and you specify that as "ChildCollection". The currencymanager of the form then keeps the two in sync behind the scenes. Check for an example the Northwind VB.NET example for adapter on the website simple_smile

Also, If the user changes the details of a child entity and I save that back to the databse.... does the child collection get updated automatically? Will the child collection also be updated with entites I add or remove (for a specific parent entity)

You're working directly with the collection, and the entities in the grid are teh entities in the child collection, so changing one, or adding one will be effective on the collection and the entities you change.

Removing an entity requires you to use a unitofwork.

Many thanks for all your help.... I am nearly getting there with this firebird smart client app that I am building - my first proper chunky test of LLBL collections etc, and LLBL (together with the 3rd party manager classes slightly modified) has saved me tons of time and enabled me to (for the first time actually) build a "proper" business logic layer.

smile

Frans Bouma | Lead developer LLBLGen Pro