data searching functionality is necessary in every business application. and we need to provide a fast and easy option to end-user to select appropriate record from big tables like product list, invoice list etc.
here is a framework class to create look-up forms for your applications. its very simple one. i created it for my applications and found very useful.
i would like to share it with you. i am sure it will save your time from creating please check it.
you can create look-up object with lookupdata class from lookup.vcx
olookup = newobject("lookupdata", "lookup")
build a look-up form with a single line of code.
its very simple to build columns for a look-up window. you can do it with a simple select statement
olookup.selectcmd = [select cust_id, company, contact, title from home(2) + "\data\customer"]
but, you have to set-up a valid sql handler for sql back-ends
olookup.remote = .t.
olookup.sqlhandler = sqlconnect("myconnection", "sa", "mypass")
olookup.selectcmd = [select cust_id, company, contact, title from data..customer]
once you set selectcmd, it will automatically build look-up columns
ocolcompany = olookup.columns.column("company")
?ocolcompany.columndata && prints "company"
?olookup.columns.column("cust_id").columncaption && prints "cust id"
each column object would have following properties.
columndata - set/return source data field for a column. column must exists in selectcmd
columncaption - set/return caption for a column. by default, non-underscore+proper case form of columndata would be columncaption.
columnname - set/return column name
columnorder - set/return relative order of a column
columnvisible - set/return visible state of a column
columnwidth - set/return width of a column. if we set -1 as columnwidth, column will automatically fit to contents
sortable - set/return whether a column is available to sort by clicking on column header.
headerimage - set/return path of a image file to display on column header.(available only if column is not sortable)
key - set/return a unique key for a column.
following properties/methods available for lookup class
autocenter - manage lookup window's autocenter property
caption - set/return lookup caption
icon - set/return icon file for look-up window
imagesort_up - set/return image file to display in column header, when column is sorted on ascending order.
imagesort_down - set/return image file to display in column header, when column is sorted on descending order.
selectcmd - set/return a valid select statement to build columns
setdefaultcolumn - method to set default search column
setkeycolumn - method to set return column
showlookup - method to show lookup window
remote - specify whether data is collect from a remote server
sqlhandler - specify a valid sql handler. only available if remote is set to .t.
tmpalias - set/return a temp alias name for underlying cursor.
casesensitive - on/off case sensitive search
please find latest file here