tracker issue : CF-4197798

select a category, or use search below
(searches all categories and all time range)
Title:

Binding a cfgrid to a cfc throws JavaScript error when the cfc returns an empty dataset

| View in Tracker

Status/Resolution/Reason: Closed/Fixed/Fixed

Reporter/Name(from Bugbase): Chris LeJeune / Chris LeJeune (Chris LeJeune)

Created: 11/15/2016

Components: AJAX, UI Components

Versions: 2016,11.0

Failure Type: Incorrect w/Workaround

Found In Build/Fixed In Build: CF2016_Update3 / 2016.0.04.302296

Priority/Frequency: Normal / All users will encounter

Locale/System: Arabic / Win 2012 Server x64

Vote Count: 0

Listed in the version 2016.0.04.302561 Issues Fixed doc
Problem Description:
When my cfgrid is bound to a cfc method that returns no data, I'm getting a JavaScript error.
ext-all.js:18 Uncaught TypeError: Cannot read property 'id' of undefined(…)

Steps to Reproduce:
index.cfm:
<cfform id="frmColors">
	<cfgrid name="grdColors" format="html" pagesize="5"
		bind="cfc:data.getColorsRemote({cfgridpage},{cfgridpagesize},{cfgridsortcolumn},{cfgridsortdirection})">
		<cfgridcolumn name="COLOR" header="Color" width="300">
		<cfgridcolumn name="ALT" header="Spanish" width="300">
	</cfgrid>
</cfform>

data.cfc
<cfcomponent output="false" displayname="data">
	<cffunction name="getColorsRemote" access="remote" returntype="struct" output="false">
		<cfargument name="page" type="numeric" required="true">
		<cfargument name="pageSize" type="numeric" required="true">
		<cfargument name="gridSortColumn" type="string" required="false" default="">
		<cfargument name="gridSortDir" type="string" required="false" default="">

		<cfparam name="arguments.gridSortColumn" default="COLOR">
		<cfparam name="arguments.gridSortDirection" default="ASC">

		<cfset var q = 0>

		<cfset qColors = getDataSet()>
		<cfquery dbtype="query" name="q">
			SELECT COLOR, ALT FROM qColors
				<cfif arguments.gridSortColumn NEQ "" AND arguments.gridSortDir NEQ "">
					ORDER BY #arguments.gridSortColumn# #arguments.gridSortDir#
				</cfif>
		</cfquery>

		<cfreturn queryConvertForGrid(q, arguments.page, arguments.pageSize)>
	</cffunction>

	<cffunction name="getDataSet" access="private" returntype="query" output="false">
		<!--- create dataset --->
		<cfset qColors = queryNew("COLOR, ALT","VarChar, VarChar")>

		<!--- comment out this section to return no data --->

		<!---<cfset newRow = queryAddRow(qColors, 7)>
		<cfset temp = querySetCell(qColors, "COLOR", "Red", 1)>
		<cfset temp = querySetCell(qColors, "ALT", "Rojo", 1)>
		<cfset temp = querySetCell(qColors, "COLOR", "Orange", 2)>
		<cfset temp = querySetCell(qColors, "ALT", "Naranja", 2)>
		<cfset temp = querySetCell(qColors, "COLOR", "Yellow", 3)>
		<cfset temp = querySetCell(qColors, "ALT", "Amarillo", 3)>
		<cfset temp = querySetCell(qColors, "COLOR", "Green", 4)>
		<cfset temp = querySetCell(qColors, "ALT", "Verde", 4)>
		<cfset temp = querySetCell(qColors, "COLOR", "Blue", 5)>
		<cfset temp = querySetCell(qColors, "ALT", "Azul", 5)>
		<cfset temp = querySetCell(qColors, "COLOR", "Indigo", 6)>
		<cfset temp = querySetCell(qColors, "ALT", "Indigo", 6)>
		<cfset temp = querySetCell(qColors, "COLOR", "Violet", 7)>
		<cfset temp = querySetCell(qColors, "ALT", "Violeta", 7)>--->

		<!--- end comment --->

		<cfreturn qColors>
	</cffunction>
</cfcomponent>

Actual Result:
JavaScript error:
ext-all.js:18 Uncaught TypeError: Cannot read property 'id' of undefined(…)

Expected Result:
As in CF9, I would expect to see an empty grid and no JavaScript error.

Any Workarounds:

----------------------------- Additional Watson Details -----------------------------

Watson Bug ID:	4197798

External Customer Info:
External Company:  
External Customer Name: Chris LeJeune
External Customer Email:  
External Test Config: My Hardware and Environment details:

Server Product	ColdFusion 2016

Version	2016.0.03.300466

Tomcat Version	8.0.32.0

Edition	Enterprise  

Operating System	Windows Server 2012 R2  

OS Version	6.3  

Update Level	E:/ColdFusion2016/cfusion/lib/updates/chf20160003.jar  

Adobe Driver Version	5.1.4 (Build 0001)  



Tested with IE 11 and Chrome.

Attachments:

Comments: