>
> Yes, you can use the results of virtual fields in other virtual fields. You
> may just call getSubTotal() directly though.
>
> > What is the correct way to handle this?
>
> Be aware that the virtual fields will calc every time the grid asks for a
> refresh.
>
> Paul


This is what I ended doing (thanks to Larry's help).  I'm not sure this is the 
correct way to handle the problem.  But I knew I wanted to keep everything in 
the bizobj (don't want violate one of Ed's rules - don't mix UI and Bizobjs).  
But I am concerned that the order of the calls is important and maybe timing.  
Although, I have not seen any issues.  If anyone see anything negative about 
my way - Please let me know.

I added two attributes for the child bizobj (_totalrec, _balance).  I then 
used one virtual field and one method to set the values correctly.

In the child table that contains all of my recieved payments.  I did the 
following:

def InitProperties(self):
  self._totalrec = 0
  self._balance = 0

def gettotalRec(self):
        tempCur = self.getTempCursor()
        tempCur.execute("Select sum(amt_rec) as totalrec from escoursepayments 
where fk_enroll = %s" % self.MainForm.esenroll.Record.pkid)
        try:
            myret = tempCur.Record.totalrec
            self._totalrec = myret
            self._balance = self.Parent.Record.course_cost - myret
        except:
            myret = 0
            self._totalrec = myret
            self._balance = self.Parent.Record.course_cost
        return myret
    
    def getBalance(self):
        try:
            myret = self._balance
        except:
            myret = 0
        return myret

On the Form I have the following:

hs.append(dabo.ui.dLabel(self,Caption='Total Rec'), halign="right")
        
hs.append(dabo.ui.dTextBox(self,Width=175,ReadOnly=True,RegID='courseRecID',DataSource='public.escoursepayments',DataField='totalrec'))
        hs.append(dabo.ui.dLabel(self,Caption='Balance'), halign="right")
        
hs.append(dabo.ui.dTextBox(self,Width=175,ReadOnly=True,RegID='balanceID',DataSource=self.Form.escoursepayments,
 
DataField='getBalance'))

The first DataField (totalrec) uses the virtual field.  And the second field 
uses a DataSource method (getBalance) to retrieve the data.



-- 
John Fabiani
_______________________________________________
Post Messages to: Dabo-users@leafe.com
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/200905200936.57771.jfabi...@yolo.com

Reply via email to