简体   繁体   English

cfgridupdate 标签找不到名为 doclist 的网格

[英]The cfgridupdate tag cannot find the grid named doclist

I am following this guide on creating an editable cfgrid: CFGRID GUIDE我正在按照本指南创建可编辑的 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.但是,我遇到了一个错误,它说 cfgridupdate 找不到网格名称 docgrid 但我看不出这可能是什么原因造成的。 I have a page called handle_grid.cfm, which will run one of two queries to update data.我有一个名为 handle_grid.cfm 的页面,它将运行两个查询之一来更新数据。 Can someone spot what I might be missing here?有人能发现我在这里可能遗漏的东西吗?

Master_Doc_Maint.cfm 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 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 :在您指向CFGRID 文档的链接中:

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.将网格编辑传递到包含cfgridupdate标记的页面,该标记会自动提取表单变量值并将该数据直接传递到数据源。 Using the cfquery tag gives you complete control over interactions with your data source.使用cfquery标记可让您完全控制与数据源的交互。 The cfgridupdate tag provides a much simpler interface for operations that do not require the same level of control. cfgridupdate标签为不需要相同级别控制的操作提供了一个更简单的接口。

This seems that the cfgridupdate statement should be on a separate page from the cfgrid .这似乎cfgridupdate语句应该位于与cfgrid不同的页面上。 You should have the page with the grid, edits would post to the page with cfgridupdate .您应该拥有带有网格的页面,编辑将使用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.重申 Adam 的评论,与现代 UI 库相比, CFGRID和其他 CF UI 控件完全是垃圾。 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 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 .这里有一个示例显示使用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.此外,看起来这不是问题,但在您发布的代码中还有一个额外的 ' 。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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