Editable data grid
HI, I am trying to learn how to create an editable datagrid. I have built a .cfc with a getdata function that displays data in the grid. When I add an update function and preview the girid page, I get an error saying it now cannot find the cfc. This is little harder than I thought. Can anyone help or know of a tutorial they might save me a few hours--- thank you - jim
The specified CFC forms3 could not be found. | |
| The path to the CFC must be specified as a full path, or as a relative path from the current template, without the use of mappings. | |
CODE For .cfc
<!---DISPLAY DATA IN GRID--->
<cfcomponent output="false">
<cffunction name="getData" access="remote" output="false" returntype="struct">
<cfargument name="page" type="numeric" required="true" />
<cfargument name="pageSize" type="numeric" required="true" />
<cfargument name="gridsortcolumn" type="string" required="true" />
<cfargument name="gridsortdirection" type="string" required="true" />
<cfquery datasource="crabForms" name="sheets">
SELECT formID, region, title, sheetFileName, dateModified, description
FROM dbo.worksheets
order by Region
<cfif Arguments.gridsortcolumn NEQ "" AND Arguments.gridsortdirection NEQ "">
ORDER BY #gridsortcolumn# #gridsortdirection#
</cfif>
</cfquery>
<cfreturn queryConvertForGrid(sheets, Arguments.Page, Arguments.PageSize) />
</cffunction>
<!---EDIT A WORKSHEET--->
<cffunction name="editsheets" access="remote">
<cfargument name="gridaction" type="string" required="yes">
<cfargument name="gridrow" type="struct" required="yes">
<cfargument name="gridchanged" type="struct" required="yes">
<!---LOCAL VARIABLES--->
<cfset var colname="">
<cfset var value"">
<!---GRID PROCESSING--->
<CFSWITCH expression="#Arguments.gridaction#">
<!--- Process Update--->
<cfcase value="U">
<!---Get column name and value--->
<cfset colname=StructKeyList(Arguments.gridchanged)>
<cfset value=Arguments.gridchanged[colname]>
<!---Perform actual update--->
<cfquery datasource="#THIS.dsn#">
Update dbo.worksheets
SET #colname# = '#value#'
WHERE formid= #ARGUMENTS.gridrow.formid#
</cfquery>
</cfcase>
<!---PROCESS DELETES--->
<cfcase value="D">
<!--- Perform Actual Delete--->
<cfquery datasource="THIS.dsn">
DELETE FROM dbo.worksheets
where formID=#Arguments.gridrow.formID#
</cfquery>
</cfcase>
</CFSWITCH>
</cffunction>
GRID CODE______________
<cfform>
<!---Set grid and column names/headers and specify if editable--->
<cfgrid name="sheets"
bind="cfc:forms3.getData({cfgridpage}, {cfgridpagesize}, {cfgridsortcolumn},{cfgridSortDirection})"
onchange="cfc:forms3.editsheets({cfgridaction}, <cfgridrow},{cfgridchanged})"
format="html"
striperowcolor="##FFFFCC"
striperows="yes"
title="Worksheets"
pagesize="20"
selectmode="edit"
>
<cfgridcolumn name="formID" header="formID" display="no">
<cfgridcolumn name="region" header="Region"select="yes" width="150">
<cfgridcolumn name="title" header="Title" select="yes" width="125">
<cfgridcolumn name="sheetFileName" header="FileName"select="yes" width="200">
<cfgridcolumn name="dateModified" header="Date"select="yes" width="200">
</cfgrid>
</cfform>
