Action
Editing a grid cell
Deleting a row
Inserting a row
To populate a grid from a query:
Create a new ColdFusion page named grid1.cfm with the following contents:
1
<cfquery name="empdata" datasource="CompanyInfo">
SELECT * FROM Employee
</cfquery>
<cfform name="Form1" action="submit.cfm" >
<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
the grid but not expose to an end user. You 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. The following figure shows the output of this code:
2
Procedure
Double-click the cell. You must press Return when you finish entering
the data.
Click any cell in the row and click the Delete button.
Click the Insert button. An empty row appears at the bottom of the
grid. To enter a value in each cell, double-click the cell, enter the value,
and click Return.
attribute to hide columns that you want to include in
display="No"
Creating data grids with cfgrid
597
Need help?
Do you have a question about the COLDFUSION MX 61-DEVELOPING COLDFUSION MX and is the answer not in the manual?
Questions and answers