main logo
Subject: Re: 1 to many forms, bizobjs, etc.
Author: Geof whitham
Posted: 2001/10/18 18:54:22
 
View Entire Thread
New Search


Yep that would do it everything else is ok. But I quickly cobbled together a parent child grandchild and found that everything worked as I thought it should and without the refresh.
As I had put together the response before reading your last message, I will post it anyway - it may give someone else food for thought.

As you wish to avoid the automatic creation of an empty record, then you must disable the automatic addition of child records. But you must also have a way to create new child records and ensure that after the form has been closed we still know which of the records is the childs's parent.

To do this set the LNewRecordOnNewParent to .F. in the bizobj that is a child bizobj. You can optionally set the LNewChildOnNew to .T. in the parent bizobj so that the auto generation is only controlled by the child bizobj.

To have the parent's id recorded in the child record Set the child biz objects property LFillParentKey to .T. and the associated Childs bizobj property cParentKeyField to the parent's ID fieldname e.g "iParentID" (without the quotes)

Once you have set the properties for each of the bizobjs you should then
Add a new Property iParentID
and
override the AfterNew() method of the top level bizobj with this code:

AfterNew()
LPARAMETERS tnPassThru
this.iParentID = this.GetParentKey()
RETURN tnPassThru

This code will place the value of the parent key field of the bizobj view into the new property iParentID.

We do this so that we can easily get at it in the top level bizobj method GetViewParmValue()

Override the top level only bizobj GetViewParmValue() method with this code:

GetViewParmValue()
RETURN this.iParentID

Set the property LSaveAllTableBuff to .T. in childbizobjs so that we save all edits in the view cursor not just the first.

On the form adjacent the child / grandchild textboxes/editboxes/grid controls etc place a button so that the user can create new child / grandchild records.
In the click event or method code that is called by the click event place this code to create a new record in the associated view cursor:

thisform.bochild1.new() or thisform.bochild2.new() or thisform.bograndchild.new()

where bochildN / bograndchild refers to the the child/grandchild bizobjs.

That should do it.

Because we use the Nav Toolbar>>New to create New Top Level records and the Buttons on the form to Create New Child Records. We still link parent to child bizobjs so that they display in a synchronized fashion. We can continue adding and linking any number of view cursors via their bizobjs until the form runs out of real estate.

Additional code in the click event or afternew() methods could be added, to set the focus to the desired field immediatly after the creation of the new record. And for each of the new record buttons and even the optional data entry fields could have Tab Stops set to .F. so that users can navigate more easily via the keyboard over optional data entry fields.





<i><font color="#663300">OK, I seem to be the current king of stupid questions. How about 'grdItems.refresh'? DUH!

sorry for taking your valuable time.

Virgil</font></i>


 
©2001 Geof whitham
<-- Prior Message New Search Next Message -->