fv sdfsaer wrote:
> I really want database completion.
> 
-----------------------------------------------------------
I've been working on such.

Thanks to Ed and Paul and the rest of the list the past few days, I have 
this working the way I want.

Please excuse my lack of Python and Dabo skill and knowledge but maybe 
this will give you some direction.

I have a table in PostgreSQL the ILIKE in the setWhereClause below is a 
case-insensitive match.

I have a form.
On that form I have
-------------------------------------------------------------
TEXTBOX1                      TEXTBOX2

LISTBOX (Could be list control or grid)

Sizer with the Record detail.
Label   Textbox
Label   Textbox
Label   Textbox
etc.
-------------------------------------------------------------
I used the data control wizard in class designer to auto generate
the labels and textboxes in this field.
They are bound to the bizObj in the wizard.
So when you click on a list selection it will update
these fields.

I have a onMouseLeftUp and a onMouseLeftDoubleClick.
The onMouseLeftUp is while I am browsing for a record.
The onMouseDoubleClick is when I want to process what I have selected.

-----------------------------------------------------
TEXTBOX1 is what you want to auto browse(complete).
regID = txtGenericName

TEXTBOX2 is disabled but will contain table primary key.
regID = txtGENERICID

LISTBOX regID lstbxGenericProduct

The 2 Text Boxes are not bound to a database.

Watch for email line wrap in the code below.

In the following example bizGenericProduct is defined as:
---------------------------------------------------------
Publicalchemy_Generic_ProductBizobj(dabo.biz.dBizobj):
        def afterInit(self):
                self.DataSource = "public.alchemy_generic_product"
                self.KeyField = "genericproductid"
                self.addFrom("public.alchemy_generic_product")
                self.addField("genericproductid")
                self.addField("synonym")
                self.addField("name")

        def validateRecord(self):
                """Returning anything other than an empty string from
                this method will prevent the data from being saved.
                """
                ret = ""
                # Add your business rules here.
                return ret

publicalchemy_generic_productBizobj = 
Publicalchemy_Generic_ProductBizobj(self.Connection)
        self.addBizobj(publicalchemy_generic_productBizobj)



TEXTBOX1 method as follows:
----------------------------
def onKeyUp(self, evt):
         # print self.Value
        if self.Value <> None:
                bizGenericProduct = 
self.Form.getBizobj("public.alchemy_generic_product")
                bizGenericProduct.setWhereClause("name ilike '%%%s%%'" % 
self.Value)
                bizGenericProduct.setOrderByClause("name")
                bizGenericProduct.requery()
                dsGenericProduct = 
bizGenericProduct.getDataSet(flds=("genericproductid", "name"))
                # print dsGenericProduct
                if dsGenericProduct:
                        self.Form.lstbxGenericProductName.Choices = 
[rec["name"] for rec in 
dsGenericProduct]
                        self.Form.lstbxGenericProductName.Keys  = 
[rec["genericproductid"] 
for rec in dsGenericProduct]            
                else:
                        self.Form.lstbxGenericProductName.Keys = [""]
                        self.Form.lstbxGenericProductName.Choices = [""]
                self.Form.lstbxGenericProductName.refresh()

LISTBOX method as follows:
--------------------------

def onMouseLeftDoubleClick(self, evt):
        self.Form.txtGenericName.Value = self.Value
        self.ValueMode = "Key"
        self.Form.txtGenericID.Value = self.Value
        self.ValueMode = "String"
        self.Form.refresh()
        
        try:
                cNum = str(int(self.Form.txtGenericID.Value))
        except:
                cNum = 0

        if  cNum <> 0:
                bizCompanyZ = 
self.Form.getBizobj("public.alchemy_generic_product")
                abc = bizCompanyZ.seek(self.Form.txtGenericID.Value, 
"genericproductid")
                self.Form.update()
                 # Add other code processing selection here

---------------------------------------------------------------------------
def onMouseLeftUp(self, evt):
        self.Form.txtGenericName.Value = self.Value
        self.ValueMode = "Key"
        self.Form.txtGenericID.Value = self.Value
        self.ValueMode = "String"
        self.Form.refresh()
        
        try:
                cNum = str(int(self.Form.txtGenericID.Value))
        except:
                cNum = 0

        if  cNum <> 0:
                bizCompanyZ = 
self.Form.getBizobj("public.alchemy_generic_product")
                abc = bizCompanyZ.seek(self.Form.txtGenericID.Value, 
"genericproductid")
                self.Form.update()
--------------------------------------------------------------------------

See if this is similiar to what you are asking for.
I will try to answer your questions.


Paul McNary
[EMAIL PROTECTED]


_______________________________________________
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