Whats the best way to do this?

Posts   
 
    
KastroNYC
User
Posts: 96
Joined: 23-Jan-2006
# Posted on: 25-May-2007 01:16:35   

I have an Entity let's say Customer that has a property exposing a child collection of related Order. I'm trying to create a grid which has the Customer's properties displayed and editable and I'd like to have this Grid contain a column which has an inner Grid to display (and manipulate, edit, insert, delete) Order's. The outer grid works great using the DataSource control and i'd like to stick to this (very minimal coding style) if possible for the inner grid. I'm using Adapter style entities.

Oh, and i don't want to have to make the user first select a parent Customer to manipulate child Orders. I've also noticed that if I bind the inner grid to the Customer.Order property I can display records fine but I cannot get automatic insertion, deletion and updates to work without a datasource which I can completely understand however it seems to me that there must be a way of getting this to work without having to manually handle all of the events of the inner grid.

Thanks.

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 25-May-2007 11:12:18   

I think you should manually handle the Persistence of the Master Grid, using LivePersistence = false. And in there you should attempt to save the collection recursively so the child collections would be saved too.

So automatic inserts/updates for the child collection won't be performed, but they would be executed when saving the master parent entity.

KastroNYC
User
Posts: 96
Joined: 23-Jan-2006
# Posted on: 26-May-2007 20:15:55   

So.. I guess as I asked is there a way to avoid doing this manually the answer is no..?

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 27-May-2007 23:26:14   

Right, the answer is that if you want to save the Master and the Child in the same transaction you have to set livePersistence=false and manages the performWork to save recursively. It's manual, but not more than 5 lines I guess.

David Elizondo | LLBLGen Support Team
Otis avatar
Otis
LLBLGen Pro Team
Posts: 39914
Joined: 17-Aug-2003
# Posted on: 29-May-2007 10:54:08   

Correct. the datasource works on the data send to it with the postback and saves it. It can't start a transaction at time T, postback, used does things, post back, and transaction continues, that's against the ACID principles: a transaction can't have any user interference.

Frans Bouma | Lead developer LLBLGen Pro