<!--- This example shows the CFGRID, CFGRIDCOLUMN, CFGRIDROW,
and CFGRIDUPDATE tags in action --->

<!--- use a query to show the useful qualities of CFGRID --->

<!--- If the gridEntered form field has been tripped,
perform the gridupdate on the table specified in the database.
Using the default value keyonly=yes allows us to change only
the information that differs from the previous grid --->
<CFIF IsDefined("form.gridEntered") is True>
<CFGRIDUPDATE GRID="FirstGrid" DATASOURCE="cfsnippets" TABLENAME="CourseList"  KEYONLY="Yes">
</CFIF>

<!--- query the database to fill up the grid --->
<CFQUERY NAME="GetCourses" DATASOURCE="cfsnippets">
SELECT   Course_ID, Dept_ID, CorNumber,
		 CorName, CorLevel, CorDesc
FROM     CourseList
ORDER by Dept_ID ASC, CorNumber ASC
</CFQUERY>

<HTML>
<HEAD>
<TITLE>CFGRIDCOLUMN Example</TITLE>
</HEAD>

<BASEFONT FACE="Arial, Helvetica" SIZE=2>
<BODY  bgcolor="#FFFFD5">

<H3>CFGRIDCOLUMN Example</H3>

<I>Try adding a course to the database, and then deleting it.</I>
<!--- call the CFFORM to allow us to use CFGRID controls --->
<CFFORM ACTION="cfgridcolumn.cfm" METHOD="POST" ENABLECAB="Yes">

<!--- When inserting rows while running under UNIX, you must
also specify a value for Course_ID --->
<!--- CFGRIDCOLUMN tags are used to change the parameters
involved in displaying each data field in the table--->

<CFGRID NAME="FirstGrid" WIDTH="600" QUERY="GetCourses" INSERT="Yes"
	DELETE="Yes" SORT="Yes" FONT="Tahoma" BOLD="No" ITALIC="No"
	APPENDKEY="No" HIGHLIGHTHREF="No" GRIDDATAALIGN="LEFT" GRIDLINES="Yes"
	ROWHEADERS="Yes" ROWHEADERALIGN="LEFT" ROWHEADERITALIC="No"
	ROWHEADERBOLD="No" COLHEADERS="Yes" COLHEADERALIGN="LEFT"
	COLHEADERITALIC="No" COLHEADERBOLD="No" SELECTCOLOR="Red"
	SELECTMODE="EDIT" PICTUREBAR="No" INSERTBUTTON="To insert"
	DELETEBUTTON="To delete" SORTASCENDINGBUTTON="Sort ASC"
	SORTDESCENDINGBUTTON="Sort DESC">
	<CFGRIDCOLUMN NAME="Dept_ID" HEADER="Department" HEADERALIGN="LEFT" DATAALIGN="LEFT" BOLD="Yes" ITALIC="No" SELECT="Yes" DISPLAY="Yes" HEADERBOLD="No" HEADERITALIC="Yes">
	<CFGRIDCOLUMN NAME="CorNumber" HEADER="Course ##" HEADERALIGN="LEFT" DATAALIGN="LEFT" BOLD="No" ITALIC="No" SELECT="Yes" DISPLAY="Yes" HEADERBOLD="No" HEADERITALIC="No">
	<CFGRIDCOLUMN NAME="CorName" HEADER="Name" HEADERALIGN="LEFT" DATAALIGN="LEFT" FONT="Times" BOLD="No" ITALIC="No" SELECT="Yes" DISPLAY="Yes" HEADERBOLD="No" HEADERITALIC="No">
	<CFGRIDCOLUMN NAME="CorLevel" HEADER="Level" HEADERALIGN="LEFT" DATAALIGN="LEFT" BOLD="No" ITALIC="No" SELECT="Yes" DISPLAY="Yes" HEADERBOLD="No" HEADERITALIC="No">
	<CFGRIDCOLUMN NAME="CorDesc" HEADER="Description" HEADERALIGN="LEFT" DATAALIGN="LEFT" BOLD="No" ITALIC="No" SELECT="Yes" DISPLAY="Yes" HEADERBOLD="No" HEADERITALIC="No">
	<CFGRIDCOLUMN NAME="Course_ID" HEADER="Course ID (Do Not Specify on NT)" DATAALIGN="LEFT" BOLD="No" ITALIC="No" SELECT="Yes" DISPLAY="Yes" HEADERBOLD="No" HEADERITALIC="No">
</CFGRID>

<!--- send the grid back to this page, where we will determine if
anything has changed, and thus whether to run the CFGRIDUPDATE --->
<INPUT TYPE="Submit" NAME="submit" VALUE="Apply Changes">
<INPUT type="hidden" NAME="gridEntered" VALUE="yes">

<H3>Additional Example</H3>
<P>This grid serves as an example to show how the same grid can be built
using CFGRIDROW with CFLOOP (i.e. defining the query externally rather
than in CFGRID).</P>
<!--- CFGRIDCOLUMN is used to define the container columns and
CFGRIDROW is used to define the data placed into those containers --->
<CFGRID NAME="SecondGrid" WIDTH=600 INSERT="No" DELETE="No" SORT="Yes" BOLD="No" ITALIC="No" APPENDKEY="No" HIGHLIGHTHREF="No" GRIDDATAALIGN="LEFT" GRIDLINES="Yes" ROWHEADERS="No" ROWHEADERALIGN="LEFT" ROWHEADERITALIC="No" ROWHEADERBOLD="No" COLHEADERS="Yes" COLHEADERALIGN="LEFT" COLHEADERITALIC="No" COLHEADERBOLD="No" SELECTMODE="BROWSE" PICTUREBAR="Yes">
	<CFGRIDCOLUMN NAME="Course_ID" DATAALIGN="LEFT" BOLD="No" ITALIC="No" SELECT="No" DISPLAY="No" HEADERBOLD="No" HEADERITALIC="No">
	<CFGRIDCOLUMN NAME="Dept_ID" HEADER="Department" HEADERALIGN="LEFT" DATAALIGN="LEFT" BOLD="Yes" ITALIC="No" SELECT="Yes" DISPLAY="Yes" HEADERBOLD="No" HEADERITALIC="Yes">
	<CFGRIDCOLUMN NAME="CorNumber" HEADER="Course ##" HEADERALIGN="LEFT" DATAALIGN="LEFT" BOLD="No" ITALIC="No" SELECT="Yes" DISPLAY="Yes" HEADERBOLD="No" HEADERITALIC="No">
	<CFGRIDCOLUMN NAME="CorName" HEADER="Name" HEADERALIGN="LEFT" DATAALIGN="LEFT" FONT="Times" BOLD="No" ITALIC="No" SELECT="Yes" DISPLAY="Yes" HEADERBOLD="No" HEADERITALIC="No">
	<CFGRIDCOLUMN NAME="CorLevel" HEADER="Level" HEADERALIGN="LEFT" DATAALIGN="LEFT" BOLD="No" ITALIC="No" SELECT="Yes" DISPLAY="Yes" HEADERBOLD="No" HEADERITALIC="No">
	<CFGRIDCOLUMN NAME="CorDesc" HEADER="Description" HEADERALIGN="LEFT" DATAALIGN="LEFT" BOLD="No" ITALIC="No" SELECT="Yes" DISPLAY="Yes" HEADERBOLD="No" HEADERITALIC="No">
<!--- use a CFLOOP to loop through the query and define CFGRIDROW
data each time through the loop --->
	<CFLOOP query="GetCourses">
		<CFGRIDROW DATA="#Course_ID#,#Dept_ID#,#CorNumber#,#CorName#,#CorLevel#,#CorDesc#">
	</CFLOOP>	
</CFGRID>
</CFFORM>

</BODY>
</HTML>       
