<!--- Define the iFrame page --->
<CF_IF_IFRAME TITLE="iFrame demo - Resultlist and ButtonBar tags" STYLE="#client.i_style#" INCLUDE="/menu/menu.cfm">

<!--- Check the status of the detailform --->
<CFIF isDefined("newstatus_1")>
	<!--- The parameter "newstatus_1" was passed through --->
	<CFIF newstatus_1 IS "open">
		<!--- The status for the detailform is now "open", so we need to run the query --->
		<CFSET runquery = TRUE>
	<CFELSE>
		<!--- The status for the detailform is now "closed", so we don't need to run the query --->
		<CFSET runquery = FALSE>
	</CFIF>
<CFELSE>
	<CFSET runquery = TRUE>
</CFIF>

<CFIF runquery>
	<!--- 
	  	Build up the "Where" clause for the buttonbar.
	  	The selected button is exposed in parameter "iframe_bb_value".
	  	If this parameter does not exist, it is the first time this page is called
	--->
	<CFIF isDefined("iframe_bb_value")>
		<!--- a button was selected --->
		<CFIF #iframe_bb_value# IS "ALL">
			<!--- If button "all" was selected, don't use a "where" clause --->
			<CFSET w = "">
		<CFELSE>
			<!--- Build up the "where" clause using the button value in "iframe_bb_value"--->
			<CFSET w = " WHERE Lastname LIKE '#iframe_bb_value#%' ">
		</CFIF>
	<CFELSE>
		<!--- First call, so don't use a "where" clause--->
		<CFSET w = "">
	</CFIF>
	
	<!--- 
		Build up the "Where" clause for the filter
	 --->
	<CFIF isDefined("f_country") AND f_country IS NOT "">
		<CFIF w IS "">
			<CFSET w = " WHERE nationality = '#f_country#' ">
		<CFELSE>
			<CFSET w = w & " AND nationality = '#f_country#' ">
		</CFIF>
	</CFIF>
	
	<!--- 
		Call the query and perform an "Order by" if the parameter "iframe_rs_order" exists
		Parameter "iframe_rs_order" contains the column database fieldname and 
		Parameter "iframe_rd_sortorder" contains the sorting order, ascending (ASC, default)
		or decending (DESC)
	--->
	<CFIF NOT isDefined("iframe_rs_order_1")>
		<CFQUERY NAME="List" DATASOURCE="iFrameDemo">
			SELECT *
			FROM Drivers #preserveSingleQuotes(w)#
		</CFQUERY>
	<CFELSE>
		<CFQUERY NAME="List" DATASOURCE="iFrameDemo">
			SELECT *
			FROM Drivers #preserveSingleQuotes(w)# ORDER BY #iframe_rs_order_1# #iframe_rs_sortorder_1#
		</CFQUERY>
	</CFIF>
<CFELSE>
	<CFSET List = QueryNew("dummy")>
</CFIF>

<!--- Recordset filter --->
<CFQUERY NAME="ctry" DATASOURCE="iFrameDemo">
	SELECT * FROM Countries ORDER BY description
</CFQUERY>

<CF_IF_FILTER TITLE="Filter...">
	<CF_IF_FILTER_ITEM CAPTION="Country" NAME="f_country" QUERY="ctry" DISPLAY="description" VALUE="code">
</CF_IF_FILTER>

<!--- Show the buttonbar --->
<CF_IF_ABCBAR TYPE="ALPHANUMERIC" TITLE="Last name starts with character...">

<!--- Build up the resultlist and define the columns --->
<CF_IF_RESULTLIST
	TITLE="F1 Drivers 2000"
	HELP="help.html"
	QUERY="list"
	RECORDSPERPAGE="5"	
	COLLAPSE
	COLLAPSEDEFAULT="open"
	FORMACTION="selected.cfm"
	FORMBUTTON="Delete..."	
	CONFIRM="TRUE"
	CONFIRMMESSAGE="Are you sure you want to delete the selected drivers?"
	ALLRECORDS	
	TOTALS
	EXCEL
	XML
	TABLE	
	>			
	<CF_IF_RESULTLIST_CHECKBOX NAME="driver" DBFIELD="id" DISABLEFIELD="firstname" DISABLEVALUES="Michael;David"> 
		
	<CF_IF_RESULTLIST_COLUMN CAPTION="Plane?"        SIZE="5%"  ALIGN="CENTER" DBFIELD="plane" DBFORMAT="IMAGE" IMAGELIST="0;/iframe/images/no.gif;Does not have a plane;1;/iframe/images/yes.gif;Owns a plane">
	<CF_IF_RESULTLIST_COLUMN CAPTION="Last name"     SIZE="15%" ALIGN="LEFT"   DBFIELD="lastname" LINK="ex_detail.cfm" LINKPARAMETERS="DBFIELD;id">
	<CF_IF_RESULTLIST_COLUMN CAPTION="First name"    SIZE="15%" ALIGN="LEFT"   DBFIELD="firstname">
	<CF_IF_RESULTLIST_COLUMN CAPTION="Country"       SIZE="10%" ALIGN="LEFT"   DBFIELD="nationality" LOOKUPTABLE="Countries" LOOKUPFIELDVALUE="Description" LOOKUPFIELDID="Code" SORT="FALSE">
	<CF_IF_RESULTLIST_COLUMN CAPTION="Date of birth" SIZE="10%" ALIGN="CENTER" DBFIELD="dateofbirth" DBFORMAT="DATE">
	<CF_IF_RESULTLIST_COLUMN CAPTION="Races"         SIZE="10%"  ALIGN="RIGHT"  DBFIELD="races"       SORTORDER="DESC">	
	<CF_IF_RESULTLIST_COLUMN CAPTION="Races won"     SIZE="10%"  ALIGN="RIGHT"  DBFIELD="won"         SORTORDER="DESC">
	<CF_IF_RESULTLIST_COLUMN CAPTION="WK Points"     SIZE="10%"  ALIGN="RIGHT"  DBFIELD="wkpoints"    SORTORDER="DESC">
	<CF_IF_RESULTLIST_COLUMN CAPTION="Fastest laps"  SIZE="10%"  ALIGN="RIGHT"  DBFIELD="fastestlaps" DBFORMAT="NUMBER" SORTORDER="DESC">	
	
	<CF_IF_RESULTLIST_BUTTON IMAGE="/iframe/images/edit.gif"   LINK="ex_form.cfm" LINKPARAMETERS="DBFIELD;id" ROLLOVERTEXT="Editing...">
	<CF_IF_RESULTLIST_BUTTON IMAGE="/iframe/images/delete.gif" LINK="ex_form.cfm" LINKPARAMETERS="DBFIELD;id" ROLLOVERTEXT="Delete..."  DISABLEFIELD="firstname" DISABLEVALUES="Michael;David" CONFIRM CONFIRMMESSAGE="Are you sure you want to delete this record?" CONFIRMROWID="lastname">
</CF_IF_RESULTLIST>

<CFOUTPUT>
	<A HREF="viewsource.cfm?template=#CGI.CF_TEMPLATE_PATH#" TARGET="source">View source</A>
</CFOUTPUT>

</CF_IF_IFRAME>