On Sunday 18 July 2010 01:21:49 pm Bronwyn Woods wrote:
> Hi,
>
> I've been making good progress on customizing an App Wizard application for
> my first Dabo project, but I have a question about working with grids
> (specifically a grid derived from the datanav Grid, if that makes a
> difference). I would like to add columns to the grid based on information
> calculated from several tables. Specifically, I have the table already
> linked to the grid (say, table A). I also have another table serving as a
> many-to-many link between table A and table B. I would like to add another
> column to the grid saying how many items in table B are linked to each item
> in table A. Is this possible? It clearly requires a way of assigning data
> beyond the DataSource and DataField properties. Is this what DataSet is
> for?
>
> Thanks,
> Bronwyn
>
BizObj's have several features that I will attempt to explain in hopes that
one of them will meet your needs.
1. When you define a bizobj class it is possible to add all the normal
SQL "select " operators (not sure that's the right name for what I'm
describing). Such as you can use 'joins', 'subqueries', special 'where'
clauses, 'group by', and 'order by'.
In your case you might want to add a 'join'
self.addJoin('tableNameToAdd', 'HereAddtheOnStatement', joinType='Left')
or maybe a where
self.addWhere("someDate > (now()::date-30)
It is also possible to manually set the SQL statement used by the bizobj.
self.UserSQL = "Select somefield, etc..."
2. Bizobj's have a very useful feature - VitualFields. You create a field
that is associated with a method/function. I use virtual fields to sum, or
any other special need I make require.
self.VirtualFields={"stat":self._getStat}
def _getStat(self):
return someSortOfStat
3. Also a bizobj can be a View. So you can define any View in the database
and it can be used. The only issue is you will have to handle the
update,insert,delete in code.
Bizobj's have many more features (almost anything you can do in a select can
be done using the available methods of dabo.biz.dBizobj).
A DataSet is nothing more that a python tuple containing dicts (a record).
You define what is in the DataSet via the bizobj class (it's also possible to
define via a DataSource). A DataSet looks like
({'pkid':1,'lname':'Smith','fname':'John'},
{'pkid':2,'lname':'Doe','fname':'John'})
Hopes this helps.
Johnf
_______________________________________________
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]