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: