tracker issue : CF-4199532

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

[ANeff] Bug for: old percent width grid regression

| View in Tracker

Status/Resolution/Reason: Closed/Fixed/Fixed

Reporter/Name(from Bugbase): Aaron Neff / Aaron Neff ()

Created: 08/23/2017

Components: AJAX, UI Components

Versions: 2016,2018

Failure Type: Enhancement Request

Found In Build/Fixed In Build: 2016.0.01.298513 / 312331

Priority/Frequency: Minor / Very few users will encounter

Locale/System: / Platforms All

Vote Count: 0

Thought I'd logged this years ago, but cannot find the ticket.

CF8 allowed cfgrid width to be percentage value. CF9+ doesn't (throws "height/width attribute cannot be a percentage value."). Workaround is simple, but CF could resolve the issue simply by removing that restriction (allowing width to be passed thru to grid's div CSS).

This worked in CF8, but fails in CF9+:
<cfform>
  <cfgrid format="html" name="myGrid" width="50%">
    <cfgridcolumn name="myColumn">
    <cfgridrow data="my value">
  </cfgrid>
</cfform>

Workaround 1 (wrap the grid w/ a %-width div):

<cfform>
  <div style="width:50%;">
  <cfgrid format="html" name="myGrid">
    <cfgridcolumn name="myColumn">
    <cfgridrow data="my value">
  </cfgrid>
  </div>
</cfform>

Workaround 2 (pass thru width CSS to grid's HTML):

<cfsavecontent variable="myGridHTML">
<cfform>
  <cfgrid format="html" name="myGrid">
    <cfgridcolumn name="myColumn">
    <cfgridrow data="my value">
  </cfgrid>
</cfform>
</cfsavecontent>
<cfscript>
  string function workaround(required string gridHTML, required string gridWidth) {
	  var result = ARGUMENTS.gridHTML;
	  var divRegex = '<div  id="cfgrid[0-9]+" style="[^"]+">';//match grid's opening div
	  var divMatches = result.reFind(divRegex, 1, true, "all");//find matches
	  if(divMatches.len()) {
		  divFixed = divMatches[1].match[1].replace('">', ' width: #ARGUMENTS.gridWidth#;">');//pass thru width
		  result = result.reReplace(divRegex, divFixed);//update HTML
	  }
	  return result;
  }
  writeOutput(workaround(myGridHTML, "50%"));
</cfscript>

Workaround #1 is obviously simple, but workaround #2 shows how CF could just-as-easily resolve the issue internally.

After fixing this issue, then the cfgrid doc would be correct again. Description for width contains: "In HTML format, can be in any valid CSS measurement unit, and a numeric-only value specifies pixels."

My hunch is that this ticket will be closed as "Won't Fix", but it just boggles my mind how time was spent creating an exception to disallow %-based widths when they actually work just fine when passed-thru to the HTML.

Related URL: https://helpx.adobe.com/coldfusion/cfml-reference/coldfusion-tags/tags-g-h/cfgrid.html

Attachments:

Comments:

Regarding the grid rendering issue that occurs when the browser is stretched wider after initial page load, that issue also occurs when cfgrid's width attribute is omitted. So that should not be a determining factor in the decision to remove the numeric-only width restriction. And, besides, _that_ issue can be resolved for AJAX grids by adding a listener to the browser's "resize" event, to call the grid's refresh() method.
Comment by Aaron N.
389 | August 23, 2017 07:26:28 AM GMT
Hi Adobe, I see the status changed from "Conflicts with the Docs" to "Enhancement Request". Are you saying it does -not- conflict w/ the docs? The cfgrid doc description for "width" says: "In HTML format, can be in any valid CSS measurement unit, and a numeric-only value specifies pixels". (that was correct in CF8) (that was the original behavior) Thanks!, -Aaron
Comment by Aaron N.
390 | August 24, 2017 06:38:47 AM GMT