On Jan 27, 2010, at 1:18 AM, Mike wrote:

> I need to change the Datasource property because I have form with two
> grids which show different parts of the same table and so they cant both
> have the same datasource


        For a bizobj, 'DataSource' is the name of the underlying table it 
represents. If you change it, the queries will now try to pull data from that 
new name, which is probably not what you want. The 'DataSource' is not an 
arbitrary name; it indicates the 'source' of the 'data' for the bizobj.

        If you need multiple bizobjs for the same table, you'll have to do a 
little coding. First, in the form's createBizobjs() method, you'll need to 
store references to these bizobjs. Let's say the table is 'foo', and you want 
to create two bizobjs for this

def createBizobjs(self):
    conn = self.Application.getConnectionByName("Foo")
    self.foo1 = self.Application.biz.FooBizobj(conn)
    self.addBizobj(self.foo1)
    self.foo2 = self.Application.biz.FooBizobj(conn)
    self.addBizobj(self.foo2)


        Now you have two instances of the bizobj stored as attributes of the 
form. Next, you'll have to override the form's getBizobj() method:

def getBizobj(self, dataSource=None, parentBizobj=None):
        if dataSource == 'foo1':
                return self.foo1
        elif dataSource == 'foo2':
                return self.foo2
        else:
                return super(ThisFormClass, self).getBizobj(
                        dataSource=dataSource, parentBizobj=parentBizobj)

        Now you can set the DataSource property of your controls to either 
'foo1' or 'foo2', and they will be bound the the correct bizobj.


-- Ed Leafe



_______________________________________________
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]

Reply via email to