On Mar 8, 2007, at 1:40 PM, VGSoftware wrote:

> I have this in escola.cdxml:
> ...
> <dDropdownList sizerInfo="..." DataSource="escolas"
> designerClass="controlMix" ValueMode="Key" Name="dTextBox6"
> DataField="distrito"></dDropdownList>

        How did a dropdown list get a Name like 'dTextBox6'?  ;-)

> In escola-code.py this:
> ...
>     def getAvailableTypes(self):
>             crs = self.getTempCursor()
>             crs.execute("select id, nome from distritos order by  
> nome")
>             ds = crs.getDataSet()
>             # Create the lists
>             names = [rec["nome"] for rec in ds]
>             keys = [rec["id"] for rec in ds]
>             return (names, keys)
> ...

        That's in the code for the form? For what object? It should be in  
the code for the business object that is responsible for the  
'distritos' table.

> Do i have to add a Choices and Keys properties with the values??  
> how do
> i retrive them from the DB??

        In the afterInit of the dropdown list control, do the following:

def afterInit(self):
        biz = self.Form.getBizobj("distritos")
        self.Choices, self.Keys = biz.getAvailableTypes()

> Also, if i need two or more lists in the same form how do i do it with
> getAvailableTypes??

        You could modify that method to accept parameters, and use those  
params to figure out what to return. Or you could create several  
methods, one for each return type. Remember, this is just a generic  
example; there is nothing magic about the name. The important idea is  
that the UI elements ask the bizobj for their possible values, and  
that you can use the Choices and Keys properties to display the plain  
text options to the user, while binding the associated PK of that  
option to the database.

-- Ed Leafe
-- http://leafe.com
-- http://dabodev.com



_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-users

Reply via email to