Groups | Blog | Home
all groups > coldfusion flash integration > september 2005 >

coldfusion flash integration : Display search results from Flash Form to CFGrid


dpinder123
9/15/2005 12:00:00 AM
Yet another CF flash form question:

I'm not sure if this is possible, but, I would like to display search results
using flash forms and display the results in a grid. Is that possible? I would
think so.....

Code attached.

<!--- Search: search for order --->
<cfif IsDefined ("FORM.searchBTN")>
<cfgridupdate grid="searchGrid" datasource="User" tablename="dbo.mortgageLog"
keyonly="yes">

<!---search QUERY--->
<cfquery name="searchOrders" datasource="User">
SELECT
fileNumber,
fileName
FROM dbo.mortgageLog
WHERE fileName LIKE '%#FORM.fileName#%'
ORDER BY fileNumber

</cfquery>
<!---end of Search--->
</cfif>



<cfform action="untitled2.cfm" format="flash">
<cfinput type="text" name="fileNameSearch" label="File Name" width="200">
<cfinput type="button" name="searchBTN" value="search" id="Search">

<cfformgroup type="panel" label="Results">
<cfgrid name = "searchGrid" rowheaders="false" height="120" width="700"
align="top">
<cfgridcolumn name="fileNumber" header="File Number" width="100">
<cfgridcolumn name="fileName" header="File Name">
</cfgrid>
</cfformgroup>
<!---end of fourth tab--->


</cfform>
ptoretti
9/16/2005 12:46:05 AM
I think this will do what you want.

dpinder123
9/17/2005 8:35:43 PM
tried that, i get this error:



Attribute validation error for tag CFGrid.
The value of the attribute Query, which is currently "searchOrders", is
invalid.

The error occurred in C:\Inetpub\wwwroot\intranet\untitled2.cfm: line 25

23 :
24 : <cfformgroup type="panel" label="Results">
25 : <cfgrid name = "searchGrid" rowheaders="false" query="searchOrders"
height="120" width="700" align="top">
26 : <cfgridcolumn name="fileNumber" header="File Number" width="100">
27 : <cfgridcolumn name="fileName" header="File Name">
PaulH
9/18/2005 12:00:00 AM
if this is all the code, build an empty query to stuff into the cfgrid when you
first enter the form or put the cfgrid into the "searchBTN" logic. you're
simply trying to display a query that doesn't (yet) exist.

dpinder123
9/19/2005 12:00:00 AM
I thought that's what I was doing:

When searchBTN is clicked, the query is executed. I've used this method with an Insert form.....am I missing something when it comes to searching?

PaulH
9/19/2005 6:55:31 PM
the cfif block that does the update also creates the cfquery that you use in your cfgrid (as ptoretti suggested). first time into the form that query doesn't exist.
dpinder123
9/22/2005 12:00:00 AM
Ok, color me stupid, but, if I'm understanding you correctly, this should work
by my nesting everything in the if block......right? Well, I did that and now,
the page wont display the flash form.

Note that this problem doesnt happen when I'm using a regular form, just a
flash form.



<!--- Search: search for order --->
<cfif IsDefined ("FORM.searchBTN")>

<!---search QUERY--->
<cfquery name="searchOrders" datasource="User">
SELECT
fileNumber,
fileName
FROM dbo.mortgageLog
WHERE fileName LIKE '%#FORM.fileNameSearch#%'
ORDER BY fileNumber

</cfquery>
<!---end of Search--->




<cfform action="untitled2.cfm" format="flash">
<cfinput type="text" name="fileNameSearch" label="File Name" width="200">
<cfinput type="button" name="searchBTN" value="search" id="Search">

<cfformgroup type="panel" label="Results">
<cfgrid name = "searchGrid" rowheaders="false" height="120" width="700"
align="top">
<cfgridcolumn name="fileNumber" header="File Number" width="100">
<cfgridcolumn name="fileName" header="File Name">
</cfgrid>
</cfformgroup>
<!---end of fourth tab--->


</cfform>
</cfif>
ptoretti
9/22/2005 12:00:00 AM
Don't nest the whole form. If you do that, you'll never see it! Just nest the
<CFGRID>. I'd do it with 2 if's so that you can keep your query visually
outside of the form. Of course, this is minimally less efficient, but to my
mind it is clearer.

<!--- Search: search for order --->
<cfif IsDefined ("FORM.searchBTN")>

<!---search QUERY--->
<cfquery name="searchOrders" datasource="User">
SELECT
fileNumber,
fileName
FROM dbo.mortgageLog
WHERE fileName LIKE '%#FORM.fileNameSearch#%'
ORDER BY fileNumber

</cfquery>
<!---end of Search--->

</cfif>


<cfform action="untitled2.cfm" format="flash">
<cfinput type="text" name="fileNameSearch" label="File Name" width="200">
<cfinput type="button" name="searchBTN" value="search" id="Search">

<cfformgroup type="panel" label="Results">
<cfif IsDefined ("FORM.searchBTN")>
<cfgrid name = "searchGrid" rowheaders="false" height="120" width="700"
align="top">
<cfgridcolumn name="fileNumber" header="File Number" width="100">
<cfgridcolumn name="fileName" header="File Name">
</cfgrid>
</cfif>
</cfformgroup>
<!---end of fourth tab--->


</cfform>
</cfif>
PaulH
9/22/2005 12:00:00 AM
dpinder123
9/22/2005 7:17:59 PM
a dummy query? do you mean populating the grid with say "ID" but not displaying it when the page loads?

dpinder123
9/22/2005 7:22:30 PM
Tried it, it just sits there.....

I thought it would work though.....makes sense......

dpinder123
9/23/2005 9:51:32 PM
ptoretti
9/23/2005 10:02:01 PM
PaulH
9/24/2005 6:30:57 AM
i actually had somethng like this in mind. but i expect you're leaving
something out of all this. what's the logic flow for this? are you experiencing
this the first time into the page? are you submitting the form? are you trying
some flash remoting?

<cfparam name="searchOrders" type="query"
default="#queryNew('fileName,fileNumber')#">
dpinder123
9/26/2005 12:00:00 AM
Nothing out of the ordinary (at least, I didnt think so):

User inputs a file name to search
Click submit
The form submits to itself
PaulH
9/26/2005 12:00:00 AM
then you need a dummy query or some logic to handle the fact that there is no query the first time into the form.
dpinder123
9/26/2005 6:25:50 PM
I added the empty query code at the top. The search results still arent
popuating into the grid.
I am losing my mind! :confused;



<cfparam name="searchOrders" type="query"
default="#queryNew('fileNumber,fileName')#">


<!--- Search: search for order --->
<cfif IsDefined ("FORM.searchBTN")>

<!---search QUERY--->

<cfquery name="searchOrders" datasource="User">
SELECT
fileNumber,
fileName
FROM dbo.mortgageLog
WHERE fileName LIKE '%#FORM.fileNameSearch#%'
ORDER BY fileNumber

</cfquery>
<!---end of Search--->

</cfif>



<cfform action="untitled2.cfm" format="flash">
<cfinput type="text" name="fileNameSearch" label="File Name" width="200">
<cfinput type="submit" name="searchBTN" value="search" >
<cfformgroup type="panel" label="Results">
<cfif IsDefined ("FORM.searchBTN")>
<cfgrid name = "searchGrid" rowheaders="false" height="120" width="700"
align="top">
<cfgridcolumn name="fileNumber" header="File Number" width="100">
<cfgridcolumn name="fileName" header="File Name">
</cfgrid>
</cfif>
</cfformgroup>

</cfform>
ptoretti
9/26/2005 10:19:39 PM
dpinder123
9/27/2005 1:39:26 AM
THANK YOU!

dpinder123
9/27/2005 1:40:17 AM
AddThis Social Bookmark Button