3 Replies - 562 Views - Last Post: 07 April 2014 - 05:49 AM Rate Topic: -----

#1 braddorl  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 15
  • Joined: 06-March 14

NOOB Hits a Brick Wall With CFGRID

Posted 03 April 2014 - 05:08 AM

I come begging for direction again after slamming head-on into a brick wall. Since all my previous experience has been in Access, I am lost on how to create a "form:subform" concept in CF. So, I consulted my trusty sidekick Google and found this article: Creating Subforms with CFGRID

Excellent! I can have one form where the top section contains the main record and another section (the CFGRID) has all the comments and/or deficiencies associated with that record. Just what I want! Sorta!

I got it to work, but for several of the columns I need a <select> that provides the user with pre-defined data. So I tried this:
<cfgridcolumn name="gridQDCategory" 
			  header="Category"
			  headeralign="LEFT" 
			  dataalign="LEFT" 
			  bold="No" 
			  italic="No" 
			  display="Yes" 
			  headerbold="Yes" 
			  headeritalic="No">
			    <cfquery name="qCat" datasource="dashboard" dbtype="ODBC">
			    SELECT * FROM ValtblCategory ORDER BY CategoryID 
			    </cfquery>
			    <select name="Cat" id="idCat">
				<cfoutput>
					<option value="" selected>-- Select Category --</option>
				<cfloop query="qCat">
					<option value="#CategoryID#">#CategoryDescrip# </option>
				</cfloop>
				</cfoutput>
				</select>




I believe the computer laughed at me and my ignorance. But it did give me exactly what I asked for: a fancy cfgrid of the columns I designated and a fully functional <select>, just outside the grid. Not what I wanted, but Garbage In Garbage Out. So my question is "How do I achieve the concept of a subform (multiple records) related to a single record and still allow <select> options for some of the fill in the blanks?"

Because of the variability in comments associated with a record I don't believe hard coding a bunch of rows and controlling the visibility as a row is completed is the answer.

TIA,
Randy

Is This A Good Question/Topic? 0
  • +

Replies To: NOOB Hits a Brick Wall With CFGRID

#2 braddorl  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 15
  • Joined: 06-March 14

Re: NOOB Hits a Brick Wall With CFGRID

Posted 03 April 2014 - 06:09 AM

Updated code to this:

<cfquery name="qCat" datasource="dashboard" dbtype="ODBC">
	SELECT * FROM ValtblCategory ORDER BY CategoryID 
</cfquery>
<cfset listCatID = ValueList(qCat.CategoryID)>
<cfset listCatDescrip = ValueList(qCat.CategoryDescrip)>		   
			    
<cfgridcolumn name="gridQDCategory" 
			  header="Category"
			  headeralign="LEFT" 
			  dataalign="LEFT" 
			  bold="No" 
			  italic="No" 
			  display="Yes" 
			  headerbold="Yes" 
			  headeritalic="No"
			  type="combobox" 
			  values = "#listCatID#" 
			  valuesDelimiter = ","
			  valuesDisplay = "#listCatDescrip#">




Now I need to see if I can get it to all work together. Wish me luck because my head hurts!
Was This Post Helpful? 0
  • +
  • -

#3 Craig328  Icon User is offline

  • I make this look good
  • member icon

Reputation: 1926
  • View blog
  • Posts: 3,471
  • Joined: 13-January 08

Re: NOOB Hits a Brick Wall With CFGRID

Posted 07 April 2014 - 05:14 AM

Braddorl, when you say "it did give me exactly what I asked for...not what I wanted" what is it that you mean? What is it you want that you're not seeing?

CFGRID (and other CFFORM type controls) are kind of a throwback to much earlier days in CF when the owners of the language (probably Allaire) decided that they could help the developer not just do much of the difficult back end stuff (ie: getting data from databases) but also help them on the front end presentation layer. What CFFORM does is it supplies a raft of CF server produced Javascript and embeds it into your page. To see it, look at your page in your browser and then do a "view source". You should see a bunch of JS code that you didn't put there. That is the CFFORM stuff at work.

I mention this because CFFORM was considered, built and deployed in the pre Web 2.0 days (pre Ajax). While the CFFORM tags are still there and they work, all of the CF UI components (like CFFORM, CFGRID, CFCHART, etc) are obsolete these days. Much of that work is now typically done by things like jQuery, various 3P chart engines and so on. CF devs typically don't like not having control over their output and once you're using CFFORM(and CFGRID by association) you don't have it. Indeed, the link you quoted was an article from 1999 and the magazine that it was in, CFDJ, was discontinued many years ago. CFGRID is an old tech that's simply not used much anymore.

I guess I mention all that to say this: I'll be glad to help you get where you'd like to be but in the 15 years I've been using CF, I've never once used CFGRID. We can muddle through your issue together though so if you haven't yet arrived at your solution, please consider taking a screenshot of your browser with your grid, posting that pic here and explaining what it is that it's doing and what it is that you want it to do.
Was This Post Helpful? 0
  • +
  • -

#4 braddorl  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 15
  • Joined: 06-March 14

Re: NOOB Hits a Brick Wall With CFGRID

Posted 07 April 2014 - 05:49 AM

Craig,
Through trial and error development. I was able to get the CFGRID to work with dropdown selections. It just does not work like I expected...

1. The dropdowns only work by mouse selection. In other words I cannot start typing the first few letters and it select the appropriate option.

2. I can't seem to control the header properties css. I believe this is because the server here is limited to html and will not allow flash.

3. Following the article, I have not been able to code a working record update cfm. I believe this is more a problem with me, than anything else. Since I am new to this I am trying to apply Access concepts that are probably not appropriate i.e. record selectors to scroll through existing records.

I appreciate your patience with me. I have attached a screenshot as .pdf with notes added. And below is the code:

Webpage for adding records:
<link href="/qa/dashboard/styles/dasboard.css" type="text/css" rel="stylesheet" media="screen, projection"/>
<link href="/style/print.css" type="text/css" rel="stylesheet" media="print"/>

<style type="text/css"> <!---This does nothing --->
#myformid
.x-grid3-cell-inner { white-space:normal;} 
.x-grid-row td {white-space:normal; text-decoration: none;}
.x-grid-hd-text {background-color: #4F658C; color: #EEEEEE; font-size: 120%; font-weight: bold;}
.x-grid-row-over td {background-color: #999999;}
.x-grid-hd-row td {white-space:normal; text-decoration:none; vertical-align:bottom}
</style>

<!---Begin Data Entry Form --->	
<div id="page-content">

<h3 class="title">Quality Dashboard Data Entry</h3><br/>

<!---<div class="raised" style="font-size:12px;padding:5px;display:inline-block;">--->

<cfform name="DataEntry" id="myformid" method="post" class="form noprint" action="inputaction.cfm">

 	<table style="width=100%;" class="datasheet">
    	<tr>
	  		<td width=5% align="left">Date:&nbsp;</td>
      		<td width=10%>
            	<cfinput type="datefield" name="RecordDate" size="13" validateat="onsubmit" validate="usdate"  required="yes"  value= '' message="You must enter a date">
      		</td>
		
			<td width=5% align="left">Ship: </td>

<!---Query for Ship Name --->			
<cfquery name="qship" datasource="tasktrack">
	SELECT * FROM shipinfo ORDER BY SHIPNAME
</cfquery>
			<!---Populate cfselect with Ship Names from the shipinfo file in Task Track db --->
			<td width=15%>
				<select name="SelectShip" required="yes" >
            	<cfoutput>
					<option value="" selected>-- Select Ship --</option>
				<cfloop query="qship">
					<option value="#UIC#" <!---<cfif selectShipDD is #UIC#>selected</cfif>--->>#SHIPNAME# #TYPE# #HULL#</option>
				</cfloop>
				</cfoutput>			   		
				</select>
			</td>
			
			<td width=5% align="left">TWD/QAWB/QSP: </td>
<!---Query for Job/TWD --->			
<cfquery name="qTWD" datasource="dashboard" dbtype="ODBC">
	SELECT * FROM valTblJobs ORDER BY JobLastUpdated DESC
</cfquery>
			<!---Populate cfselect with Job/TWD Information from the valTblJobs file in Dashboard db --->
			<td width=15%>
				<select name="SelectTWD" required="yes" message="You must select a Job or Add New Job.">
            	<cfoutput>
					<option value="" selected>-- Select TWD --</option>
				<cfloop query="qTWD">
					<option value=#JOBID# >#JOB# </option>
				</cfloop>
				</cfoutput>			   		
				</select>
			</td>
<!---Need to add onclick event to fire a Pop-up Window to add New Job to ValtblJobs in Dashboard db --->			
			<td width=10% align="left" colspan="2">
				<!---<cfinput type="Submit"  name="AddNewJob" value="Add New Job" width="100"></td>--->
		</tr>
		
		<tr>
			<td colspan="8"><br></td>
			
		</tr>
			
		<tr>
			<td width=5% align="left">Type: </td>
<!---Query for TypeofReview --->			
<cfquery name="qTypeReview" datasource="dashboard" dbtype="ODBC">
	SELECT * FROM valTblTypeReview ORDER BY ReviewTypeID
</cfquery>
			<!---Populate cfselect with Type of Review from the valTblTypeReview file in Dashboard db --->
			<td width=15%>
				<select name="SelectTypeReview" onchange="targ=document.getElementById('idSelForm'); this.value=='2'? targ.style.visibility='visible' : targ.style.visibility='hidden';" required="yes" message="You must select a Type of Review.">
            	<cfoutput>
					<option value="" selected>-- Select Review Type --</option>
				<cfloop query="qTypeReview">
					<option value="#ReviewTypeID#" >#TypeofReview# </option>
				</cfloop>
				</cfoutput>			   		
				</select>
			</td>

			<td width=5% align="left">Source: </td>
<!---Query for Source --->			
<cfquery name="qSource" datasource="dashboard" dbtype="ODBC">
	SELECT * FROM valTblSource ORDER BY SourceID
</cfquery>
			<!---Populate cfselect with Source from the valTblSource file in Dashboard db --->
			<td width=15%>
				<select name="SelectSource" required="yes" message="You must select a Source."
				onchange="targ=document.getElementById('idExtOrg'); this.value=='2'? targ.style.visibility='visible' : targ.style.visibility='hidden';">
            	<cfoutput>
					<option value="" selected>-- Select Source --</option>
				<cfloop query="qSource">
					<option value="#SourceID#" >#SourceType# </option>
				</cfloop>
				</cfoutput>			   		
				</select>
			</td>

			<td width=5% align="left">NCR/CAR Required: </td>
<!---Query for NCR/CAR --->			
<cfquery datasource="dashboard" dbtype="ODBC" name="qNCRCAR">
	Select * FROM ValTblNCRCARAnswer ORDER BY NCRCARID;
</cfquery>
			<!---Populate cfselect with NCR/CAR Requirement from the valTblNCRCARAnswer file in Dashboard db --->
			<td width=15%>
				<select name="SelectNCRCAR" required="yes" message="You must select an answer."
				onchange="targ=document.getElementById('idNCRCARnum'); this.value>'1'? targ.style.visibility='visible' : targ.style.visibility='hidden';">					
            	<cfoutput>
					<option value="" selected>-- Select Response --</option>
				<cfloop query="qNCRCAR">
				<option value="#NCRCARID#">#NCRCARANSWER#</option>
				</cfloop>
				</cfoutput>			   		
			</select>
			</td>
	
			<td width=5% align="left">Auditor: </td>
<!---Query for Auditor --->			
<cfquery datasource="tasktrack" dbtype="ODBC" name="qAuditor">
	Select * FROM empmf ORDER BY EMF_EMPL_NAME;
</cfquery>
			<!---Populate cfselect with Auditor from the Employee file in Task Track db --->
			<td width=15%>
				<select name="SelectAuditor" required="yes" message="You must select an Auditor.">
            	<cfoutput>
					<option value="" selected>-- Select Auditor --</option>
				<cfloop query="qAuditor">
				<option value="#EMF_EMPL_ID#">#EMF_EMPL_NAME#</option>
				</cfloop>
				</cfoutput>			   		
			</select>
			</td>
		</tr>
</table>

<!---Additional Information Based on Responses to Selections in Previous Table --->
<table width="100%" class="datasheet">
		<tr>
		
				<td width=17% align="left">Form Type: </td>
				<td align="left">
<!---Query to get Form Types --->
<cfquery name="qForms" datasource="dashboard" dbtype="ODBC">
	Select * FROM ValtblQAForms ORDER BY QAFORMID
</cfquery>
			<!---Populate cfselect with Form Types from the ValTblQAForms file in dashboard db --->
				<select id="idSelForm" name="SelectForm" style="visibility:hidden;" message="You must select a Form.">
            	<cfoutput>
					<option value="" selected>-- Select Form --</option>
				<cfloop query="qForms">
					<option value="#QAFORMID#">#QAFORMNUM# #QAFORMDescrip#</option>
				</cfloop>
				</cfoutput>			   		
				</select>
				</td>
		
		</tr>
		<tr>			
			
				<td width=17% align="left">Enter External Organization: </td>
				<td  align="left" colspan="2">
				<cfinput type="text" id="idExtOrg" style="visibility:hidden;" name="ExtOrg" size="50">
				</td>
			
		</tr>
		<tr>	
		
				<td width=17% align="left" >Enter CAR or NCR Number: </td>
				<td align="left">
				<cfinput type="text" id="idNCRCARnum" style="visibility:hidden;" name="NCRCARnum" size="50">
				</td>
			
		</tr>
	</table>
<p>




<!---This begins the grid for comment entry --->
<cfgrid name="CommentSubForm"
		format="html"
		autowidth="No"
		selectmode="edit" 
		insert="YES" 
 		insertbutton="Insert Comment" 
 		delete="YES" 
 		deletebutton="Delete Comment">
		

<cfgridcolumn name="tblQDLog_ID" display="false"  >
<cfgridcolumn name="QDCommentID" display="false"  > 

<cfgridcolumn name="QDStepNum" 
			  header="Step"
			  headeralign="LEFT" 
			  width="25"
			  dataalign="LEFT" 
			  bold="No" 
			  italic="No" 
			  display="Yes" 
			  headerbold="Yes" 
			  headeritalic="No">
			    
<cfgridcolumn name="QDComment"  
			  header="Comment"
			  width="250"
			  headeralign="LEFT" 
			  dataalign="LEFT" 
			  bold="No" 
			  italic="No" 
			  display="Yes" 
			  headerbold="Yes" 
			  headeritalic="No">
			   
<cfquery name="qCat" datasource="dashboard" dbtype="ODBC">
	SELECT * FROM ValtblCategory ORDER BY CategoryID 
</cfquery>
<cfset listCatID = ValueList(qCat.CategoryID)>
<cfset listCatDescrip = ValueList(qCat.CategoryDescrip)>		   
			    
<cfgridcolumn name="QDCategory" 
			  header="Category"
			  headeralign="LEFT" 
			  dataalign="LEFT" 
			  bold="No" 
			  italic="No" 
			  display="Yes" 
			  headerbold="Yes" 
			  headeritalic="No"
			  type="combobox" 
			  values = "#listCatID#" 
			  valuesDelimiter = ","
			  valuesDisplay = "#listCatDescrip#">

<cfquery name="qRootCause" datasource="dashboard" dbtype="ODBC">
	SELECT RootCauseID, RootCauseDescrip FROM ValtblRootCauses ORDER BY RootCauseID
</cfquery>
<cfset listRCid = ValueList(qRootCause.RootCauseID)>
<cfset listRCDescrip = ValueList(qRootCause.RootCauseDescrip)>			   		   		    
				
<cfgridcolumn name="QDRootCause" 
			  header="Root Cause"
			  headeralign="LEFT" 
			  width="150"
			  dataalign="LEFT" 
			  bold="No" 
			  italic="No" 
			  display="Yes" 
			  headerbold="Yes" 
			  headeritalic="No"
			  values = "#listRCID#" 
			  valuesDelimiter = ","
			  valuesDisplay = "#listRCDescrip#">

<cfquery name="qAssess" datasource="dashboard" dbtype="ODBC">
	SELECT * FROM ValtblAssessment ORDER BY AssessmentID
</cfquery>
<cfset listAssessID = ValueList(qAssess.AssessmentID)>
<cfset listAssess = ValueList(qAssess.Assessment)>
		    	
<cfgridcolumn name="QDAssessment" 
			  header="Assessment"
			  headeralign="LEFT" 
			  dataalign="LEFT" 
			  bold="No" 
			  italic="No" 
			  display="Yes" 
			  headerbold="Yes" 
			  headeritalic="No"
			  values = "#listAssessID#" 
			  valuesDelimiter = ","
			  valuesDisplay = "#listAssess#">

<cfquery datasource="tasktrack" dbtype="ODBC" name="qEmp">
	Select * FROM empmf ORDER BY EMF_EMPL_ID;
</cfquery>
<cfset listEmpID = ValueList(qEmp.EMF_EMPL_ID)>
		    
<cfgridcolumn name="QDCraftsman" 
			  header="Craftsman"
			  headeralign="LEFT" 
			  dataalign="LEFT" 
			  bold="No" 
			  italic="No" 
			  display="Yes" 
			  headerbold="Yes" 
			  headeritalic="No"
			  <!---values = "#listEmpID#" 
			  valuesDelimiter = ","
			  valuesDisplay = "#listEmpID#"--->>
			  
<cfgridcolumn name="QDSupervisor" 
			  header="Supervisor"
			  headeralign="LEFT" 
			  dataalign="LEFT" 
			  bold="No" 
			  italic="No" 
			  display="Yes" 
			  headerbold="Yes" 
			  headeritalic="No"
			  <!---values = "#listEmpID#" 
			  valuesDelimiter = ","
			  valuesDisplay = "#listEmpID#"--->>
			    
<cfgridcolumn name="QDInspector" 
			  header="Inspector"
			  headeralign="LEFT" 
			  dataalign="LEFT" 
			  bold="No" 
			  italic="No" 
			  display="Yes" 
			  headerbold="Yes" 
			  headeritalic="No"
			  <!---values = "#listEmpID#" 
			  valuesDelimiter = ","
			  valuesDisplay = "#listEmpID#"--->>
			    
</cfgrid>
<p>
	<input type="Submit" Value="Submit Record">

</cfform>





</div>

</div>
<!-- All content will end here -->

<!--- This includes the formatted footer --->
<cfmodule template="/qa/dashboard/includes/footer.cfm">




Code for writin records to db in the inputaction.cfm:
<cftransaction> 

<cfif FORM.SelectTypeReview NEQ '2' >
	<cfset Form.SelectForm = '1'>
</cfif>
	
<cfif FORM.SelectNCRCAR EQ '1' >
	<cfset Form.NCRCARNum = 'NA'>
</cfif>

<cfquery datasource="dashboard" name="inputLogInfo"> 
INSERT INTO DatatblQDLog(QDLogDate, QDLogShip, QDLogJob, QDLogAuditor,
QDLogType, QDLogSource, QDLogFormType, QDLogNCRCARREQDResponse, QDLogNCRCAR ) 
VALUES('#FORM.RecordDate#', '#FORM.SelectShip#', '#FORM.SelectTWD#', '#FORM.SelectAuditor#',
'#FORM.SelectTypeReview#', '#FORM.SelectSource#', '#FORM.SelectForm#', '#FORM.SelectNCRCAR#','#FORM.NCRCARnum#' ) 
</cfquery> 

<cfquery datasource="Dashboard" name="getValtblJobID">
	SELECT JobID, Job FROM ValtblJobs WHERE jobid = #Form.SelectTWD#
</cfquery>

<cfset UpdateJobID = #getValtblJobID.JOBID#>

<cfquery datasource="dashboard" name="LogUpdateDate">
	UPDATE ValtblJobs 
	SET 
	JobLastupdated = #CreateODBCDateTime(FORM.RecordDate)# 
	WHERE JobID = #UpdateJobID# 
</cfquery>


<cfgridupdate 
 datasource="dashboard" 
 tablename="DatatblQDComments" 
 grid="CommentSubForm" 
 > 
  
<cfquery datasource="dashboard" name="getID"> 
SELECT  MAX(QDLogID) AS theID 
FROM DatatblQDLog 
</cfquery> 

<cfif Form.SelectSource EQ '2'>
	<cfquery datasource="dashboard" name="inputExtInfo"> 
		INSERT INTO tblExternalSource(ExtAuditor, LogQDID ) 
		VALUES('#FORM.ExtOrg#', '#getID.thID#' ) 
	</cfquery>
</cfif> 
  
<cfquery datasource="dashboard" name="settblQDLog_ID"> 
UPDATE DatatblQDComments 
SET 
 tblQDLog_ID = #getID.theID# 
WHERE IsNull(tblQDLog_ID)
</cfquery> 

</cftransaction> 


Attached File(s)


Was This Post Helpful? 0
  • +
  • -

Page 1 of 1