Nate Lowrie wrote: > On Wed, Apr 23, 2008 at 6:41 AM, Karsten Weinert > <[EMAIL PROTECTED]> wrote: >> Extending the question asked a few days ago, how can I handle 1:[1,0] >> relationships? >> Assume I have a master table with some information and a details table >> that may or may not >> have optional info, but at most one row. >> >> In the minimal example below I can teach my form >> to display this optional info, but by default, if I enter new optional >> info, and move >> forward and back through the masters dataset, the entered information is >> lost. >> >> I added a onValueChanged handler which creates a new details row if >> there is none, but >> this seems not practical for two reason. First, if I enter a new >> optional info and >> *directly* move to the next master's row (by hitting next) and then back, >> the >> information is still lost. Second, in my real form I have several data >> controls for >> the "details" table and it seems too tedious to add a event handler >> for each of these >> controls. >> >> Do you have another suggestion on how to handle this situation? > > Karsten, > > In this case, I would make your Details Bizobj a child of your Master > bizobj. What you need to do is set the following on the Details: > - FillLinkFromParent = True > - LinkField = "master_fk" > > In the Master Bizobj, you need to call the following method: > - bizobj.addChild(DetailsBizobjReference) > > Now, if you call new on your Master bizobj, you can call new on your > details bizobj and have the link through the master_fk automatically > established. > > Uwe, I wouldn't do what you are proposing. It defeats the purpose of > refactoring the details table out, not to mention with blank fields > it's not the best design. Code overhead should be low enough where it > is more beneficial to stick with the 1 or 0 relationship. > > Hope this helps. > > Nate L.
I didn't meant to store an empty record. But in order to be able to fill the child record, you have to call new on it. If the user doesn't fill a child field, you can always call cancel on the child record. There is no need to save an unused record. But if you don't know the use case, it's hard to suggest how to do it. I have a better example. Say i want to insert a new record in a user table (user of your app or database). A user is a person. In order to insert a user record there has to be a person record. In this use case i wouldn't put the fields of the two records on one form to be able to create a user record. I would add a button to link a person record to the user record. I would display some fields of the person record, but wouldn't let the user change fields of the person record when he wants to add a user record. Person fields and user fields get changed on different forms but not on one and the same form. Instead of two forms i eventually would use two tabs on the same form. In the above use case person is a child record of user! Uwe _______________________________________________ Post Messages to: [email protected] Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-users Searchable Archives: http://leafe.com/archives/search/dabo-users This message: http://leafe.com/archives/byMID/[EMAIL PROTECTED]
