Populating A Grid From A Query - MACROMEDIA COLDFUSION 5-DEVELOPING Develop Manual

Table of Contents

Advertisement

154

Populating a grid from a query

To populate a grid from a query:
1
2
3
Reviewing the code
The following table describes the highlight code and its function:
Code
<cfgrid name="employee_grid"
selectmode="single">
<cfgridcolumn NAME="Emp_ID">
<cfgridcolumn
NAME="LastName">
<cfgridcolumn name="Dept_ID">
Open a new file named
Edit the file so that it appears as follows:
<cfquery name="empdata" datasource="CompanyInfo">
SELECT * FROM Employee
</cfquery>
<cfform name="Form1" action="submit.cfm" method="Post">
<cfgrid name="employee_grid" query="empdata"
selectmode="single">
<cfgridcolumn name="Emp_ID">
<cfgridcolumn name="LastName">
<cfgridcolumn name="Dept_ID">
</cfgrid>
<br><input type="Submit" value="Submit">
</cfform>
Note
Use the
cfgridcolumn display
include in the grid but not expose to an end user. You would typically use this
attribute to include columns such as the table's primary key column in the results
returned by
cfgrid
Save the file and view it in your browser.
query="empdata"
in ColdFusion Studio.
grid1.cfm
="No" attribute to hide columns you want to
without exposing this data to the user.
Description
Create a grid named "employee_grid" and
populate it with the results of the query
"empdata".
Allow the user to select only one cell. Other
modes are row, column and edit.
Put the contents of the Emp_ID column in the
query results in the first column of the grid.
Put the contents of the LastName column in the
query results in the second column of the grid.
Put the contents of the Dept_ID column in the
query results in the third column of the grid.
Chapter 9 Building Dynamic Forms

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the COLDFUSION 5-DEVELOPING and is the answer not in the manual?

Questions and answers

This manual is also suitable for:

Coldfusion 5

Table of Contents