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



我遵循本指南创建可编辑的cfgrid:CFGRIDE guide

然而,我遇到了一个错误,它说cfgridupdate找不到gridname docgrid,但我看不出这可能是由哪里引起的。我有一个名为handle_grid.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

<!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>

在CFGRID文档的链接中:

在";创建可编辑网格":

将网格编辑传递给包含cfgridupdate标记的页面,该标记会自动提取表单变量值,并将该数据直接传递给数据源。使用cfquery标记可以完全控制与数据源的交互。cfgridupdate标签为不需要相同级别控制的操作提供了一个简单得多的接口。

这似乎cfgridupdate语句应该与cfgrid在一个单独的页面上。你应该有一个带有网格的页面,编辑会发布到带有cfgridupdate的页面。你把它们放在同一页上。

重申Adam的评论,与现代UI库相比,CFGRID和其他CFUI控件简直就是垃圾。如果这是新代码,我建议用以下代码之一替换此网格:

  • https://datatables.net/
  • https://www.ag-grid.com/

更新:

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

这里有一个示例显示了在使用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> 

相关内容

  • 没有找到相关文章