简体   繁体   中英

The cfgridupdate tag cannot find the grid named doclist

I am following this guide on creating an editable cfgrid: CFGRID GUIDE

However, I am running into an error where it's saying cfgridupdate cannot find the gridname docgrid but I can't see where this could be caused. I have a page called handle_grid.cfm, which will run one of two queries to update data. Can someone spot what I might be missing here?

Master_Doc_Maint.cfm

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<!-- Importing jquery libraries -->
<title>Master List Maintenance</title>
<!--- Make sure the person running is an admin. --->
<cfif NOT listfindnocase(application.admins,application.wsl_cdsid)>
Sorry. You are not listed as an admin.
  <cfabort>
</cfif>


<!--- Get all the data from the database. --->
<cfquery datasource="mydatastore name="get_all_docs">
SELECT SITE,SECTIONS,TAB,DOC_NUMBER,DESCRIPTION,REV_LEVEL,REVISION_DATE,REVIEW_DATE,ADMIN,ACTIVE from MDL_MASTER_LIST 
   ORDER BY SITE,sections,TAB,DOC_NUMBER
</cfquery>

<cfform name="docgrid" action="handle_grid.cfm" > <!-- calls the handle program to process the changed data --> 

<cfgrid name="doclist" align="Top" autowidth="yes" bgcolor="FFF" colheaderbold="yes" selectmode="edit"
 format="html" griddataalign="left" gridlines="yes" query="get_all_docs" sort="yes" striperowcolor="FC6" striperows="yes"
 width=1650  insert="Yes" delete="yes">

<cfgridcolumn name="Site" width="100">
<cfgridcolumn name="Sections" width="100">
<cfgridcolumn name="Doc_Number" width="100" select="No">
<cfgridcolumn name="Description" width="300">
<cfgridcolumn name="Rev_Level" width="100">
<cfgridcolumn name="Revision_Date" width="100">
<cfgridcolumn name="Review_Date" width="100">
<cfgridcolumn name="Admin" width="100">
<cfgridcolumn name="Active" width="100">

</cfgrid>
<br>
<cfinput name="UpdateDocs" type="Submit" value="Update">

</cfform>

<cfgridupdate grid="doclist"
datasource="mydatastore"
tablename="MDL_MASTER_LIST">

Click <a href="Master_Doc_Maint.cfm">here</a> to display updated grid.

</head>

<body>

</body>
</html>

handle_grid.cfm

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Master List Maintenance</title>
</head>
<!--- Make sure the person running is an admin. --->
<cfif NOT listfindnocase(application.admins,application.wsl_cdsid)>
Sorry. You are not listed as an admin.
  <cfabort>
</cfif>
<body>

<h3>Grid values for Form.firstgrid row updates</h3>

<cfif isdefined("Form.docgrid.rowstatus.action") is True>

<cfloop index = "counter" from = "1" to =
#arraylen(Form.docgrid.rowstatus.action)#>

<cfoutput>
The row action for #counter# is:
#Form.docgrid.rowstatus.action[counter]#
<br>
</cfoutput>

<cfswitch expression="#Form.docgrid.rowstatus.action[counter]#">
<cfcase value = "U">
<cfquery name="query_insert" datasource="mydatastore">
UPDATE MDL_MASTER_LIST
SET
    active = <cfqueryparam value = '#form.docgrid.active[counter]#' CFSQLType="CF_SQL_VARCHAR">,
    admin = <cfqueryparam value = '#form.docgrid.admin[counter]#' CFSQLType="CF_SQL_VARCHAR">,
    description = <cfqueryparam value = '#form.docgrid.description[counter]#' CFSQLType="CF_SQL_VARCHAR">,
    doc_number = <cfqueryparam value = '#form.docgrid.doc_number[counter]#' CFSQLType="CF_SQL_VARCHAR">,
    is_contact = <cfqueryparam value = #form.docgrid.is_contact[counter]# CFSQLType="CF_SQL_VARCHAR">,
    is_file = <cfqueryparam value = #form.docgrid.is_file[counter]# CFSQLType="CF_SQL_VARCHAR">,
    review_date = <cfqueryparam value = #createodbcdate(form.docgrid.review_date[counter])# CFSQLType="CF_SQL_DATE">,
    revision_date = <cfqueryparam value = #createodbcdate(form.docgrid.revision_date[counter])# CFSQLType="CF_SQL_DATE">,
    rev_level = <cfqueryparam value = '#form.docgrid.rev_level[counter]#' CFSQLType="CF_SQL_VARCHAR">,
    sections = <cfqueryparam value = '#form.docgrid.sections[counter]#' CFSQLType="CF_SQL_VARCHAR">,
    site = <cfqueryparam value = '#form.docgrid.site[counter]#' CFSQLType="CF_SQL_VARCHAR">,
    tab = <cfqueryparam value = '#form.docgrid.tab[counter]#' CFSQLType="CF_SQL_VARCHAR">
WHERE doc_number = <cfqueryparam value = '#form.docgrid.original.doc_number[counter]#' CFSQLType="CF_SQL_VARCHAR">
</cfquery>
</cfcase>
<cfcase value ="D">
         <cfquery name="query_delete" datasource="mydatastore">
            DELETE FROM MDL_MASTER_LIST WHERE doc_number = <cfqueryparam value = '#form.docgrid.original.doc_number[counter]#' CFSQLType="CF_SQL_VARCHAR">
         </cfquery>
      </cfcase>'
      </cfswitch>
</cfloop>
</cfif>

Click <a href="Master_Doc_Maint.cfm">here</a> to display updated grid.

</body>
</html>

In your link to the CFGRID docs :

Under "Creating an editable grid":

Pass grid edits to a page that includes the cfgridupdate tag, which automatically extracts the form variable values and passes that data directly to the data source. Using the cfquery tag gives you complete control over interactions with your data source. The cfgridupdate tag provides a much simpler interface for operations that do not require the same level of control.

This seems that the cfgridupdate statement should be on a separate page from the cfgrid . You should have the page with the grid, edits would post to the page with cfgridupdate . You have them both on the same page.

To reiterate Adam's comment, CFGRID and the other CF UI controls are straight trash compared to modern UI libraries. If this is new code, I would recommend replacing this grid with one of these:

Update:

https://helpx.adobe.com/coldfusion/cfml-reference/coldfusion-tags/tags-gh/cfgridupdate.html

There's an example here that shows a condition check before using cfgridupdate .

<!--- If the gridEntered form field exists, the form was submitted. Perform gridupdate. ---> 
<cfif IsDefined("form.gridEntered") is True> 
    <cfgridupdate grid = "FirstGrid" 
        dataSource = "cfdocexamples" Keyonly="true" 
        tableName = "CourseList"> 
</cfif> 

Do you have the stack trace of the error? Also it doesn't look like this is the issue but there's an extra ' after in the code you posted.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM