Copy link to clipboard
Copied
I'm getting quite frustrated as I've tried a couple of features now that I've had to abandon because they don't seem to work - cflayout tabs results in broken tabs which look awful, so I've abandoned that and gone with a different approach. This time I wanted to use cfgrid with bound data. I've followed the video tutorial at lynda.com and I've also reproduced the example in Ben Forta's new CF9 Web Application Construction Kit. The plain grid ones work fine but, once I bind the data, I don't get any data rendered in the cfgrid - all I get is a loading icon that just keeps spinning round.
The Ajax debug window shows that the data's definitely being retrieved from the database but it's not being put into the grid. I wanted to use it to edit entries on one of the tables in the database but I can't get it to work! I usually refer to the application variables for the datasource etc but a post from the past about it suggested the application variables can't be accessed with this function and I've changed it for now to see if that has any effect. Here's the code, if anyone knows why I might not be able to get it to work, please let me know:
FORM:
<!--- Display Grid --->
<cfform>
<cfgrid name="imageGrid"
format="html"
width="700px"
pagesize="10"
striperows="yes"
title="Images Table"
bind="cfc:images.browse({cfgridpage},
{cfgridpagesize},
{cfgridsortcolumn},
{cfgridsortdirection})">
<cfgridcolumn name="imagesID"
header="Images ID"
display="no" />
<cfgridcolumn name="imagefilename"
header="Image Filename"
display="yes" />
<cfgridcolumn name="propID"
display="false" />
<cfgridcolumn name="propertyname"
header="Property Name"
display="true" />
</cfgrid>
</cfform>
CFC:
<!--- Browse Images --->
<cffunction name="browse"
access="remote"
returnType="struct"
hint="Browse method for Ajax grid">
<cfargument name="page"
type="numeric"
required="yes">
<cfargument name="pageSize"
type="numeric"
required="yes">
<cfargument name="gridsortcolumn"
type="string"
required="no"
default="">
<cfargument name="gridsortdir"
type="string"
required="no"
default="">
<!--- Local variables --->
<cfset var images="">
<cfquery name="images" datasource="*********" username="**********" password="***********">
SELECT *
FROM images
INNER JOIN properties ON images.propID = properties.propID
<cfif ARGUMENTS.gridsortcolumn NEQ "" and ARGUMENTS.gridsortdir NEQ "">
ORDER BY #ARGUMENTS.gridsortcolumn# #ARGUMENTS.gridsortdir#
</cfif>
</cfquery>
<!--- And return it as a grid structure --->
<cfreturn QueryConvertForGrid(images,
ARGUMENTS.page,
ARGUMENTS.pageSize)>
</cffunction>
Copy link to clipboard
Copied
Forget it, have found the answer! I have includes in an onRequestStart and in onRequestEnd and another onRequestEnd function. This means that the cfc calls the onRequestStart and onRequestEnd as well as the page calling them and this causes the problem. There is a post on Forta Forums from Ray Camden about it in answer to someone else's problem with this. The solution is to put in a <cfargument name="thePage" type="string" required="true"> where the name can be whatever you like and you put this straight after the onRequestStart and the onRequestEnd line and then you enclose the cfincludes &, in my case, the other function that's also in the onRequestEnd in this cfif: <cfif listLast(arguments.thePage, ".") NEQ "cfc">
Hope this helps someone else - it certainly solved my problem. Now I just have to make it editable ....
Here's hoping that goes well!
Copy link to clipboard
Copied
hi Merlinsmum,
Can you point me to the link that fixes this cfgrid (cf9) problem? Thanks!
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more