How-to create a combo box that is
constrained to a parent table
by Curtis Krauskopf
1) Create a relates-to constraint between the
child table and parent table in the DDOs (Data Dictionary
Object) of the WBO (Web Business Object).
2) In the ASP code, tell the WBO to find the
parent row (or record) in the parent DDO.
<% err = oWbo.requestFindByRecID("parentName",
parent_recId) %>
3) In the ASP code, find the default record in
the child DDO (this is optional and this step can be
skipped)
One way to do this:
<% err = oWbo.requestFindByRecID("childName",
child_recId) %>
4) Use the following template to create a combo
box for the child.
The real work is done on the ddvalue() line.
<form name=ComboSelect action="NextPage.asp" method="POST">
<table border="0">
<tr>
<td>
<select SIZE="1" NAME="ChildName__Recnum" >
<%=oWbo.ddvalue("childName.key", DDRECS) %>
</select>
</td>
</tr>
</table>
</form>
Notes:
- oWbo is the name of the
web business object. Use an appropriate WBO
name, such as oCustomer, or oOrderDetail.
- parentName is the DataFlex
name of the parent file of the relates-to constraint
set up in step 1.
- childName is the DataFlex
name of the child file of the relates-to constraint
defined in step 1.
- parent_recID and child_recID
both contain appropriate integers. child_recID
is only needed if the affect in step 3 is desired.
- In the example, the name of the selection object
is ChildName__Recnum.
This should be changed to an appropriate name.
If you don't do this, two or more combo boxes on the
same page will have the same name and that will cause
problems.
- There is a way to make the ComboBox automatically
submit when the user clicks on an item (assuming they
have JavaScript enabled), This
example shows how to make a drop-down box automatically
submit when an item is selected.
Go Back to the WebApp
Server and ASP Tips Page
Other Popular DataFlex topics at The Database Managers,
Inc.:
|