Trying to change CFGRID column color

I am trying to use the below example to change the color of a grid column based on output. The difference between my grid and the example below is, my grid uses a "bind" to the query. Can someone help me understand what I need to change (other than taking out the loop)?

Thank you.

<cfajaximport/>
<html>

<head>
<script>
		
myf = function(data,cellmd,record,row,col,store) {
	if(data == "Product 4") return "<font color='red'>" + data + "</font>";
	else if(data == "Product 5") return "<font color='green'>" + data + "</font>";
	else return data;
}
testgrid = function() {
	mygrid = ColdFusion.Grid.getGridObject('data');
	cm = mygrid.getColumnModel();
	cm.setRenderer(0, Ext.util.Format.usMoney);
	cm.setRenderer(1,myf);
	mygrid.reconfigure(mygrid.getStore(),cm);
}
</script>
</head>

<body>

<cfset data = queryNew("price,product")>
<cfloop from=1 to=10 index="x">
	<cfset total = randRange(20,100) & "." & randRange(1,99)>
	<cfset product = "Product #X#">
	<cfset queryAddRow(data)>
	<cfset querySetCell(data, "price", total+0, x)>
	<cfset querySetCell(data, "product", product, x)>
</cfloop>

<cfform name="test">
<cfgrid autowidth="true" name="data" format="html" query="data" width="600">
   <cfgridcolumn name="price" header="Price">
   <cfgridcolumn name="product" header="Product">
</cfgrid>
</cfform>

<cfset ajaxOnLoad("testgrid")>
</body>
</html>

Open in new window

earwig75Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Gurpreet Singh RandhawaCEOCommented:
what version of coldfusion you are using

please check the following tutorials if they can help you in any case:

http://www.experts-exchange.com/articles/10751/Cfgrid-and-Row-Clicking-and-editing-using-underlying-EXT-JS.html

the change you have to make is in extJS
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ColdFusion Language

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.