HowToSetupParent-Child-Grandchild

From Dabo Wiki
Jump to: navigation, search

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...