Yes, Virginia, you can put HTML into a CFGRID

This is pretty good - I didn’t realize till I tried but you can put HTML into a CFGRID. Consider the following:

<cfset foo = queryNew("title,picture,age")> <cfloop from="1" to="10" index="x"> <cfset queryAddRow(foo)> <cfset querySetCell(foo, "title", "This is <b>row</b> #x#")> <cfset querySetCell(foo, "picture", "<img src='http://www.raymondcamden.com/images/me.jpg' width='100' height='100'>")> <cfset querySetCell(foo, "age", randrange(18,56))> </cfloop>

<cfform name=”goo”> <cfgrid name=”mydata” format=”html” query=”foo”> <cfgridcolumn name=”title” header=”Title”> <cfgridcolumn name=”picture” header=”Picture” width=”100”> <cfgridcolumn name=”age” header=”Age”> </cfgrid> </cfform> </code>

I used HTML in two columns here. The title column uses a bold tag, and the picture column is an image. I’m sure folks could come up with some interesting users for this. You could use an image to flag a row for example (active versus not active). For a live demo of this, see here:

http://www.coldfusionjedi.com/demos/gridwithhtml.cfm

Raymond Camden's Picture

About Raymond Camden

Raymond is a developer advocate. He focuses on JavaScript, serverless and enterprise cat demos. If you like this article, please consider visiting my Amazon Wishlist or donating via PayPal to show your support. You can even buy me a coffee!

Lafayette, LA https://www.raymondcamden.com

Comments