g127404
asked on
CFGRID finding column names
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?ta bletoedit= #url.table toedit#" 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>
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__
<cfdump var="#FORM#">
</cfif>
<cfquery datasource="foxpro" name="#url.tabletoedit#">
Select *
From #url.tabletoedit#
</cfquery>
<cfform action="edit_tables.cfm?ta
<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>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
do a CFDUMP of form.__CFGRID__CFFORM_2__G RIDEDIT 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.
ASKER
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__G RIDEDIT 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.
The CFDUMP of form.__CFGRID__CFFORM_2__G
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.
Do you see the column names in the gridedit data seperated by semicolans (along with a bunch of other information)?
ASKER
in the CFDUMP of form.__CFGRID__CFFORM_2__G RIDEDIT the information is:
__CFGRID__EDIT__=5loginna meYfirst YlastY permission Yreports toY1Us gordon 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.
__CFGRID__EDIT__=5loginna
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.
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.
ASKER
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
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
Thank you very much! :)
ASKER
<cfif IsDefined("form.gridentere
<cfloop index="i" from="1" to="#ListLen(form.__CFGRID
<cfset data = ListGetAt(form.__CFGRID__C
<cfif ListGetAt(data,1,'=') is '__CFGRID__COLUMN__'>
<cfset column = ListGetAt(data,2,'=')>
<cfoutput>#column#</cfoutp
<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.