Posted in ColdFusion | Posted on 05-31-2007 | 26,531 views
So I plan to spend time later on talking more about the Ajax work in ColdFusion 8, but I thought I'd share a demo I whipped up for Ben a few weeks back. This demo integrates with Yahoo's Traffic service using my CFYahoo library. Simply enter a zip, hit Go, and the grid will populate with traffic data. When you select a row, I then use a map to show you information about the traffic hot spot.
All of the "magic" can be seen in one line:
2
3<cfgrid name="reportsGrid" format="html" pageSize="5" stripeRows="true" bind="cfc:yahooProxy.getTraffic({cfgridpage},{cfgridpagesize},{cfgridsortcolumn},{cfgridsortdirection},{zip})">
The bind attribute tells ColdFusion to speak to my CFC and use the results for the data.
The code is available below. To run this, be sure to download the CFYahoo package first. And yes - I was trying to be artsy with my design here. Normally I'm not allowed to design anything. ;)
And yes - I hope to have everything up and running on CF8 here soon.


ColdFusion.Grid.refresh
not
ColdFusion.Grid.Refresh
:o)
Rob
Nice stuff. But......tried it out, and I'm getting
ColdFusion.Grid.Refresh is not a function in the onclick of the button. What am I missing?
ColdFusion is not defined
[Break on this error] ColdFusion.Ajax.importTag('CFWINDOW');
h127424.cf8beta.c... (line 43)
ColdFusion is not defined
[Break on this error] ColdFusion.Ajax.importTag('CFFORM');
h127424.cf8beta.c... (line 47)
ColdFusion is not defined
[Break on this error] ColdFusion.Ajax.importTag('CFGRID');
h127424.cf8beta.c... (line 65)
ColdFusion is not defined
[Break on this error] ColdFusion.objectCache['reportsGrid'] = new ColdFusion.Grid.Actions('CFGRID11...
h127424.cf8beta.c... (line 69)
ColdFusion is not defined
[Break on this error] };ColdFusion.Event.registerOnLoad(_cf_bind_init_1180671087207);
h127424.cf8beta.c... (line 87)
ColdFusion is not defined
[Break on this error] };ColdFusion.Event.registerOnLoad(_cf_window_init_1180671087208);
I have tried 90502 - but it is not returning any records :-)
I don't seem to be getting any errors.
Do I need my own key/licence?
Thx
Andrew
More specifically, I have a user grid that I want to do 2 things on... the email column is clickable just as a mailto: with the email address in it and the Person's name column clicks through to the edit page and passes "person_id=" and append the value from the hidden person_id column... the best I could do was getting it to do gridkey= but I'd like to not have to change my edit code and I'd also like to be able to make different columns pass different or even multiple url variables. Am I out of luck or is there a way to actually do this?
Our existing plain vanilla grid does something like this (stripped down to basics):
<cfoutput query="theQuery">
<tr><td><a href="index.cfm?myid=#theQuery.myid#&otherid=#theQuery.otherid#">#theQuery.name#</a></td></tr>
</cfoutput>
And I'd like to do something similar with the grid. I'd also like to be able to do a mailto link.
I tried doing something like href="index.cfm?myid={personGrid.myid}" and href="mailto:{personGrid.email}" but that didn't work :)
you can probably do something like(untested): <cfajaxproxy bind="javascript:window.location.href='index.cfm?otherid='+{FormName:GridName.otherid};">
Also, with the Ext object you can write a javascript functions to do all kinds of cool stuff. here is an example of how to edit the data in a cell, save it to your db via a cfc call, and refresh the row in the grid without having to reload all the data in the grid with ColdFusion.Grid.refresh and loose your selected row.
http://www.coldfusionguy.com/ColdFusion/blog/index...
To ensure your data is formatted correctly in an HTML CFGrid, you can apply a custom renderer to the column via javascript. Ray gives an example of a currency renderer here.
http://www.coldfusionjedi.com/index.cfm/2007/8/20/...
I have an example of a custom date renderer here:
http://www.coldfusionguy.com/ColdFusion/blog/index...
Theoretically, you could make a javascript function to format the data in any way you like.
I am using cfwindow and cfgrid, all works beautifully in firefox, but in IE I get an
"Error: Unexpected call to method or property access"
the line that is references is
this.form.appendChild(this.editField);
After much frustration it seems that it is when the cfgrid is html, and I need it to be html because I an using the bind attribute for some nice ajax.
Also found that if it isn't in cfwindow then it works fine. So something with cfwindow and cfgrid being html together.
Any pointers would be much appreciated.
Before getting into analyzing and trying to fix this for IE I wondered if James or anyone else have solved similar situations by now.
fist i got heaps of error invoking CFC, internal server error.
checked the cfide folder in IIS and nothing wrong with that , nw i get this new weird error ,
Error invoking CFC /admin/CFC/filter.cfc : Element VALIDATIONHEADER is undefined in ERROR. (no idea what that means)
heres my cfgrid:
<cfgrid format="html" name="employeeGrid" pagesize=50
stripeRows=true stripeRowColor="gray"
bind="cfc:admin.cfc.filter.getfilterIP({cfgridpage},{cfgridpagesize},{cfgridsortcolumn},{cfgridsortdirection})"
delete="yes" selectmode="edit"
onchange="cfc:admin.cfc.filter.editfilterIP({cfgridaction},{cfgridrow},{cfgridchanged})">
<cfgridcolumn name="filterID" display=true header="filter ID"/>
<cfgridcolumn name="ipAddress" display=true header="IP Address"/>
<cfgridcolumn name="ipFraudRating" display=true header="Fraud Rating"/>
</cfgrid>
the path to the CFC in correct, i'm at my wits end, plz help mate>>>>
error.validationheader
and validationheader is not part of error. You need to check your error logs. This will tell you exactly that file and line this error is being thrown in. It sounds like your error validation code is actually throwing an error itself.
I can confirm this happens in IE with every editable grid I create. Why is this bug not being addressed by Adobe? I tried to post this to the live docs and of course they gonged my post. Any insight or workarounds would be appreciated.
Secondly - be sure you are running the very latest version (8.0.1 with Cumulative Hot Fix)
Edit the data, it disappears, I just tested it.
Can you bind a grid to a URL? If so, do you have some samples that I can refer to?
bind="url:foo.cfm"
You need to add the arguments for cfgrid at the end though.
bind="url:foo.cfm?page={cfgridpage}&pagesize={cfgridpagesize}&sort={cfgridsortcolumn}&sortdir={cfgridsortdirection}">
<a href="http://deepuverma.wordpress.com/2007/08/23/cfgrid-...;
http://deepuverma.wordpress.com/2007/08/23/cfgrid-...
When it is in the CellSelectionModel, it doesn't return the ID (since it now longer selects the row).
Has anyone been able to do CellSelectionModel and still keep BINDs to the grid working?
Thanks!
Chris
First, how do you bind to a cfc that is in a mapped directory? Or is it even possible?
Second, I want to send in a variable orgID that is set at the top of the page ( possibly from a url variable ) to the cfc for the query. If I put the variable in as {orgID} I get a bind error. If I use #orgID# the bind is happy. I feel like I'm missing something here. Does a {variable} have to be set using cfinput within the cfform? Hope that makes sense.
Doug
Second: Nope, if you want to hard code a value to use int he bind, the orgID is fine. And yes, {...} is meant for client side variables only.
I'm using bind="cfc:files.getFiles......" to get the data from a query. I'm also using <cfajaxproxy bind="javascript:details({files.id@click})" />, which calls a JS function to open the cfwindow. The problem is, say the user clicks on a row, the cfwindow opens, then the user closes this window by accident and they want to open this window again by clicking on the same row. It won't work unless you click on another row and go back to the previous row. Any ideas how to fix this? I've also used @change and that doesn't work. I was trying to follow this example: http://www.brianflove.com/public/cfwindow/ which has the same issue as well. Thank you!
http://www.coldfusionjedi.com/index.cfm/2007/8/9/R...
Posts 25 & 34.
THANK YOU!
http://www.coldfusionjedi.com/index.cfm/2009/4/9/A...
You could wrap your grid in a div and hide it.
<cfgrid format="html" name="Pricestandardreview" pagesize="10" bindonload="true" sort="true"
bind = "cfc:test.getSTDReview({cfgridPage},{cfgridpagesize},{cfgridsortcolumn},{cfgridsortdirection})" selectmode="edit"
onchange= "cfc:test.editSTDReview({cfGridAction},{cfgridrow},{cfgridchanged})" >
<cfgridcolumn name="full_account" display=true header="Customer Number"/>
<cfgridcolumn name="DBID" header="DBID" select="no" display=no />
<cfgridcolumn name="SCENARIO_SEQ" header="SCENARIO_SEQ" select="no" display=no />
<cfgridcolumn name="ACCOUNT_NUM" header="ACCOUNT_NUM" select="no" display=no />
<cfgridcolumn name="SCENARIO_DET_SEQ" header="SCENARIO_DET_SEQ" select="no" display=no />
<cfgridcolumn name="account_name" display=true header="Customer Name" select="no"/>
<cfgridcolumn name="tank_num" display=true header="Tank Number" select="no"/>
<cfgridcolumn name="product" display=true header="Product Code" select="no"/>
<cfgridcolumn name="department_code" display=true header="Department code" select="no"/>
<cfgridcolumn name="tank_acquired" display=true header="Tank Acquisition Date" mask="mm/dd/yyyy" select="no"/>
<cfgridcolumn name="zone" display=true header="Zone" select="no"/>
<cfgridcolumn name="tank_size" display=true header="Tank Size" select="no"/>
<cfgridcolumn name="tank_rental_amount" display=true header="Tank Rental Amount" select="no"/>
<cfgridcolumn name="tank_rental_period" display=true header="Total Rental Period" select="no"/>
<cfgridcolumn name="tank_rental_status" display=true header="Tank Rental Status" select="no"/>
<cfgridcolumn name="curr_price_sub_level" display=true header="Price Sublevel" select="no"/>
<cfgridcolumn name="minimum_bill_table" display=true header="Minimum Bill Code" select="no"/>
<cfgridcolumn name="curr_base_price_code" display=true header="Base Price Code" select="no"/>
<cfgridcolumn name="curr_deviation" display=true header="Deviation" select="no"/>
<cfgridcolumn name="gross_amount" display=true header="Gross Amount" select="no"/>
<cfgridcolumn name="r12_gallons" display=true header="Gallons" select="no"/>
<cfgridcolumn name="new_base_price_code" display=true header="New Bpc" select="yes" />
<cfgridcolumn name="new_deviation" display=true header="New Deviation" select="yes" />
<cfgridcolumn name="new_price_per_gallon" display=true header="New Price" select="no" />
<cfgridcolumn name="PRICE_VARIANCE" display=true header="Price Variance" select="no" />
<cfgridcolumn name="TOTAL_VARIANCE" display=true header="Total Variance" select="no" />
</cfgrid>
[Add Comment] [Subscribe to Comments]