Solved

CFGRID finding column names

Posted on 2006-07-06
9
550 Views
Last Modified: 2013-12-24
How do you find the column names that are returned from a CFGRID form dynamically.
I can see they are returned when I do a cfdump but don't know how to call them.

My code:



<cfif IsDefined("form.__CFGRID__CFFORM_2__GRIDEDIT") is True>
<cfdump var="#FORM#">
</cfif>

<cfquery datasource="foxpro" name="#url.tabletoedit#">
            Select *
            From #url.tabletoedit#
            </cfquery>
<cfform action="edit_tables.cfm?tabletoedit=#url.tabletoedit#" method="post" preloader="no" format="flash" height="380">
<cfgrid name="gridEdit"
            selectmode="edit"
            query="#url.tabletoedit#"
            insert="yes"
            delete="yes"
            height="300" />
<cfinput type="submit" name="submit" value="Submit">
<cfinput type="hidden" name="gridentered">
</cfform>
0
Comment
Question by:g127404
  • 5
  • 4
9 Comments
 
LVL 13

Accepted Solution

by:
usachrisk1983 earned 500 total points
ID: 17052779
What are you trying to do exactly?  If you want them dynamically, you could run this:

<cfloop index="i" from="1" to="#ListLen(form.__CFGRID__YOURFORMNAME__YOURGRIDNAME,';')#">
 <cfset data = ListGetAt(form.__CFGRID__YOURFORMNAME__YOURGRIDNAME,i,';')>
 <cfif ListGetAt(data,1,'=') is '__CFGRID__COLUMN__'>
  <cfset column = ListGetAt(data,2,'=')>
  <cfoutput>#column#</cfoutput><br>
 </cfif>
</cfloop>

This loops through all items in the "form.__CFGRID__YOURFORMNAME__YOURGRIDNAME" variable to get the data, then looks to see which are listed as columns, then grabs the item after the equal sign to get the column name.  Note that the row number is passed in there as a column to, you may want to write an ignore for that depending on what you're doing.
0
 
LVL 4

Author Comment

by:g127404
ID: 17053342
Nothing returned (or more precisely "nope" returned =-).  here is what I used:

<cfif IsDefined("form.gridentered") is True>
<cfloop index="i" from="1" to="#ListLen(form.__CFGRID__CFFORM_2__GRIDEDIT,';')#">
 <cfset data = ListGetAt(form.__CFGRID__CFFORM_2__GRIDEDIT,i,';')>
 <cfif ListGetAt(data,1,'=') is '__CFGRID__COLUMN__'>
  <cfset column = ListGetAt(data,2,'=')>
  <cfoutput>#column#</cfoutput><br>
 <cfelse>
  nope
 </cfif>
</cfloop>
</cfif>

I'm trying to make it so I can dynamically edit any of the tables in my database.  I do a cfdirectory and then create a link from each of the tables to a cfgrid.  After I make an edit to the grid I need to update it.  I've tried cfupdategrid and have had nothing but problems.  So my next option is to do it manually.  In order to do it manually I need to know the column names to know what exactly to send to the update query.
0
 
LVL 13

Expert Comment

by:usachrisk1983
ID: 17053483
do a CFDUMP of form.__CFGRID__CFFORM_2__GRIDEDIT and see if you're getting anything in there.  If not, do a CFDUMP of FORM to see what it's called when you submit.
0
Ransomware: The New Cyber Threat & How to Stop It

This infographic explains ransomware, type of malware that blocks access to your files or your systems and holds them hostage until a ransom is paid. It also examines the different types of ransomware and explains what you can do to thwart this sinister online threat.  

 
LVL 4

Author Comment

by:g127404
ID: 17053536
As stateted in my original post... the cfdump does show information.  I can see the column names and the changed data.  I just don't know how to reference them.  

The CFDUMP of form.__CFGRID__CFFORM_2__GRIDEDIT shows one long string of data
and CFDUMP of FORM shows the nice colored table of variables and data.

I'd rather not post the exact data but if you feel it will help let me know.
0
 
LVL 13

Expert Comment

by:usachrisk1983
ID: 17053611
Do you see the column names in the gridedit data seperated by semicolans (along with a bunch of other information)?
0
 
LVL 4

Author Comment

by:g127404
ID: 17053678
in the CFDUMP of form.__CFGRID__CFFORM_2__GRIDEDIT the information is:
__CFGRID__EDIT__=5loginnameYfirstYlastYpermissionYreportstoY1Usgordon sgordon  Scott  Scott Gordon Gordon      anotheruserprice

So the column names are loginname, first, last, permission, and reportsto
I don't see semicolons... in firefox and internet explorer both - it shows the box you see above.
0
 
LVL 13

Expert Comment

by:usachrisk1983
ID: 17053894
Looks like it's different if the grid selectmode is set to EDIT.  I don't see a method to get them, but someone may come up with something sneaky to figure it out -- I'll keep thinking though.
0
 
LVL 4

Author Comment

by:g127404
ID: 17126035
I finally got it to work.  I found cfgridrow on the livedocs site had a similar approach to what you were doing and was able to modify that.
I'll give you the points since you got me going in the right direction.
http://livedocs.macromedia.com/coldfusion/6.1/htmldocs/tags-p54.htm


Thanks
0
 
LVL 13

Expert Comment

by:usachrisk1983
ID: 17126160
Thank you very much! :)
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Coldfusion update database with CFLOOP 5 64
question about access to website 2 80
System Analysis 5 62
Ways to assess https/ssl websites 3 103
Have you ever sent email via ColdFusion and thought of tracking this mail to capture the exact date and time when the message was opened ?  If yes, then this article is for you ! First we need a table user_email with columns user_id , email , sub…
When it comes to showing a 404 error page to your visitors, you do not want that generic page to show, and you especially do not want your hosting provider’s ad error page to show either. In this article, I will show you how to enable the custom 40…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

820 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question