Difference between revisions of "HowToSetupParent-Child-Grandchild"

From Dabo Wiki
Jump to: navigation, search
(Created page with "You will get the full benefit of this document by first watching the screencasts "Using the Data Environment" parts 1 & 2. First, create the bizobjs. I'm assuming that you've...")
 
 
Line 1: Line 1:
 
You will get the full benefit of this document by first watching the screencasts "Using the Data Environment" parts 1 & 2.
 
You will get the full benefit of this document by first watching the screencasts "Using the Data Environment" parts 1 & 2.
  
First, create the bizobjs. I'm assuming that you've specified the KeyField and LinkField properties in the bizobj classes. If using the ClassDesigner, this would be located near the end of the .createBizobjs() method of the Form.
+
First, create the bizobjs. I'm assuming that you've specified the [[KeyField]] and [[LinkField]] properties in the bizobj classes. If using the [[ClassDesigner]], this would be located near the end of the <code>createBizobjs()</code> method of the Form.
  
 +
<syntaxhighlight lang="python">
 
bizParent = MyParentBizobjClass(conn)
 
bizParent = MyParentBizobjClass(conn)
 
bizChild = MyChildBizobjClass(conn)
 
bizChild = MyChildBizobjClass(conn)
 
bizGrandchild = MyGrandchildBizobjClass(conn)
 
bizGrandchild = MyGrandchildBizobjClass(conn)
 +
</syntaxhighlight>
 +
 
Now add each to its parent:
 
Now add each to its parent:
  
 +
<syntaxhighlight lang="python">
 
bizParent.addChild(bizChild)
 
bizParent.addChild(bizChild)
 
bizChild.addChild(bizGrandchild)
 
bizChild.addChild(bizGrandchild)
 +
</syntaxhighlight>
 +
 
Setting up an Parent-Child relationship, like a customer and his/her orders, is very easily done, as shown by Ed Leafe in the screencast, but what if you want to be able to not only choose a customer and order, but also view/edit the particular items in that order? I'll start by giving you some helpful hints and fill in more information, screenshots, etc, at a later date.
 
Setting up an Parent-Child relationship, like a customer and his/her orders, is very easily done, as shown by Ed Leafe in the screencast, but what if you want to be able to not only choose a customer and order, but also view/edit the particular items in that order? I'll start by giving you some helpful hints and fill in more information, screenshots, etc, at a later date.
  
In the screencast, Ed adds the code self.Form.next() to the .onHit() method of his Next button for advancing to the next customer. If you build a similar interface for the orders, with navigation buttons and text fields, you cannot use a plain self.Form.next() because it will advance to the next customer rather than the next order. You need to explicitly tell it the order's datasource:
+
In the screencast, Ed adds the code <code>self.Form.next()</code> to the <code>onHit()</code> method of his '''Next''' button for advancing to the next customer. If you build a similar interface for the orders, with navigation buttons and text fields, you cannot use a plain <code>self.Form.next()</code> because it will advance to the next customer rather than the next order. You need to explicitly tell it the order's datasource:
 +
 
 +
<syntaxhighlight lang="python">
 
def onHit(self):
 
def onHit(self):
 
   self.Form.next('orders')
 
   self.Form.next('orders')
 +
</syntaxhighlight>
 +
 
More hints to come...
 
More hints to come...

Latest revision as of 14:08, 17 May 2020

You will get the full benefit of this document by first watching the screencasts "Using the Data Environment" parts 1 & 2.

First, create the bizobjs. I'm assuming that you've specified the KeyField and LinkField properties in the bizobj classes. If using the ClassDesigner, this would be located near the end of the createBizobjs() method of the Form.

bizParent = MyParentBizobjClass(conn)
bizChild = MyChildBizobjClass(conn)
bizGrandchild = MyGrandchildBizobjClass(conn)

Now add each to its parent:

bizParent.addChild(bizChild)
bizChild.addChild(bizGrandchild)

Setting up an Parent-Child relationship, like a customer and his/her orders, is very easily done, as shown by Ed Leafe in the screencast, but what if you want to be able to not only choose a customer and order, but also view/edit the particular items in that order? I'll start by giving you some helpful hints and fill in more information, screenshots, etc, at a later date.

In the screencast, Ed adds the code self.Form.next() to the onHit() method of his Next button for advancing to the next customer. If you build a similar interface for the orders, with navigation buttons and text fields, you cannot use a plain self.Form.next() because it will advance to the next customer rather than the next order. You need to explicitly tell it the order's datasource:

def onHit(self):
   self.Form.next('orders')

More hints to come...