Coldfusion8 html cfgrid problem

26. September 2007 09:21 by Mrojas in General  //  Tags:   //   Comments (0)
We had a problem with a cfgrid
Coldfusion8 introduces an HTML cfgrid that is AWESOME!!!
It is something you should use.
It is based in the also excellent library Ext But recently we were extruglying with it because when we tried to capture exceptions in the update functions nothing happened and it was terrible because a real life application NEEDS exception handling. My code was something like this:
First file was places.cfc

<cfcomponent output="false">

<cffunction name="getData" access="remote" output="false">
<cfargument name="page">
<cfargument name="pageSize">
<cfargument name="gridsortcolumn">
<cfargument name="gridsortdirection">
<cfquery name="team" datasource="cfdocexamples">
SELECT Emp_ID, FirstName, EMail
FROM Employees
<cfif gridsortcolumn neq "" or gridsortdirection neq "">
order by #gridsortcolumn# #gridsortdirection#
<cfreturn QueryConvertForGrid(team, page, pageSize)>

<cffunction name="editData" access="remote" output="false">
<cfargument name="gridaction">
<cfargument name="gridrow">
<cfargument name="gridchanged">

<cfif isStruct(gridrow) and isStruct(gridchanged)>
<cfif gridaction eq "U">
<cfset colname=structkeylist(gridchanged)>
<cfset value=structfind(gridchanged,#colname#)>
<cfquery name="team" datasource="cfdocexamples">
update employees set aaa<cfoutput>#colname#</cfoutput> =
where Emp_ID = <cfoutput>#gridrow.Emp_ID#</cfoutput>
<cfquery name="team" datasource="cfdocexamples">
delete from employees where emp_id = <cfoutput>#gridrow.Emp_ID#


and the second file was grid2.cfm:

<html xmlns="">
<script type="text/javascript">
function errorhandler(id,message) {
alert("Error while updating\n Error code: "+id+"\n Message: "+message);

<cfform name="form01">
<cfgrid format="html" name="grid01" pagesize=11
stripeRows=true stripeRowColor="gray"
delete="yes" selectmode="edit"
<cfgridcolumn name="Emp_ID" display=true header="Employee ID"/>
<cfgridcolumn name="FirstName" display=true header="Name"/>
<cfgridcolumn name="Email" display=true header="Email"/>

And the problem where was it!!
It was not in any of those files it was in the application.cfm There was an onError handler. So it was commented out and everything work perfect! Well I just like to write down these little details so I don't make this silly things twice. I hope this can be of any help