Adobe Dreamweaver Forums



Last 10 THreads :         Changing viewState via a dynamically added button (Last Post : *gsb* - Replies : 1 - Views : 2 )           »          Limit line in select query throwing error after workingfor 2 years+ (Last Post : -==cfSearching==- - Replies : 3 - Views : 4 )           »          beginner issues (Last Post : whatisgood - Replies : 9 - Views : 10 )           »          Tips on creating a dynamic flexbook (pageflip) (Last Post : *gsb* - Replies : 7 - Views : 38 )           »          More Flash Video controller skins (Last Post : JayNewWeb - Replies : 8 - Views : 9 )           »          Adobe Flash Player 10 Fix for Vista & XP (Last Post : wofey1122 - Replies : 4 - Views : 5 )           »          Smooth load of enternal images (Last Post : openParentheses - Replies : 5 - Views : 11 )           »          This Forum only diplays one page of posts??? (Last Post : cspocspo - Replies : 0 - Views : 1 )           »          XML files manage (Last Post : *gsb* - Replies : 1 - Views : 2 )           »          What happened to text Editor? (Last Post : heathrowe - Replies : 1 - Views : 2 )           »         


Home Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
User Info Statistics
Go Back   Adobe Dreamweaver Forums > Other Macromedia/Adobe Products > Cold Fusion > Reporting
 
Tags:



Reply
  #1 (permalink)  
Old 10-15-2008, 11:24 PM
jergarmar
 
Posts: n/a
Diggs:
Default using advanced query builder for a chart

I am trying to insert a query-based chart in my report template. However, the
data is coming from a text file; thus I am creating the query object for the
chart by parsing the text file. However, the "query.name" and "query.number"
fields are not changing for each record from the original report query -- only
the first record is used. Thus the first chart on the first page is correct,
but the chart never changes for all the other pages (each page represents one
record from the query). This is what I'm putting into the advanced query
builder :

<cfset ThisQuery = QueryNew("ItemColumn,ValueColumn")>
<cfif FileExists("D:\charts\#query.name#_#query.number#. txt")>
<cfset ThisDataItem = 0>
<cfloop file="D:\charts\#query.name#_#query.number#.txt" index="ThisLine">
<cfif IsNumeric(ThisLine)>
<cfset ThisDataItem += 1>
<cfset QueryAddRow(ThisQuery)>
<cfset QuerySetCell(ThisQuery,"ItemColumn",ThisDataItem)>
<cfset QuerySetCell(ThisQuery,"ValueColumn",ThisLine)>
</cfif>
</cfloop>
</cfif>

So basically the filename is set according to first row (result) from the
report query, but then the filename (and thus the chart) never changes even
though all the other query-based fields on my page change properly (all the
other query.BlahBlah fields update correctly). Is this a bug? I didn't think I
was doing anything too crazy.



Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 10-30-2008, 01:04 AM
jergarmar
 
Posts: n/a
Diggs:
Default Re: using advanced query builder for a chart

Whew! I figured out a really awesome solution, which has a ton of uses.

First of all, as I should have realized, ANY variable in a coldfusion tag is
going to be figured out when the report is called, NOT for every query result.
In other words, query.xxx or report.xxx or whatever is NEVER going to work
correctly inside of a tag, not even in a report function or the Advanced Query
builder.

However, there is a straightforward way around this. Simply make a report
function with arguments, and in your field's expression editor call the
function and pass in the query or report variables:
#report.yourFunction(query.field1, query.field2)#
You can do all sorts of Coldfusion function magic and return whatever form of
result you want.

For my particular example (dynamically creating a query object for a chart to
be inserted), I had to add a not-so-obvious step: creating my query object with
a shared scope (in this case, the Request scope), otherwise the variable is
trapped in the function's scope. So this was my solution: I had a chart with
the "Print When" option calling my function "getChartQuery" (passing in the
query variables, of course). The function builds "Request.ThisChartQuery" and
returns True if there's something in it (the "Print When" logic uses the
boolean to decide whether to show the chart or not). Then my chart is still
query-based, but the Advanced Query builder has NOTHING in it at all, except
for the variable containing the query object ("Request.ThisChartQuery").

There was another solution I found where the report function makes the entire
chart (using cfchart tags, etc) and saves it as a PNG file, and then returns
the path to the image. Then you simply add an image field to the report, and
you use the expression builder to call the function. Well, hope this helped
someone!

Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



© Camley Interactive (camley.info) 2008 - all logos and images are copywrite their respective owners.
Proud member of the Camley Interactive Network
All times are GMT. The time now is 12:43 AM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.1.0 ©2007, Crawlability, Inc.
Inactive Reminders By Mished.co.uk