Groups | Blog | Home
all groups > coldfusion flash integration > april 2005 >

coldfusion flash integration : CFGRID row highlight programtically


nerd_boy
4/22/2005 1:07:05 PM
Can you programatically set a row to be highlighted in a CFGRID? I want to have
the first row selected every time the form is loaded so as to populate some
other fields I have in the form which are bound to the grid? Anyone got any
code that does this???
hollyjones
5/2/2005 12:00:00 AM
This will do it.

--Holly

<cfscript>
title = "Binding an image to a cfgrid with thumbnail";
properties = queryNew("id,name");
queryAddRow(properties);
querySetCell(properties,'id','1');
querySetCell(properties,'name','Tom');
queryAddRow(properties);
querySetCell(properties,'id','2');
querySetCell(properties,'name','Dick');
queryAddRow(properties);
querySetCell(properties,'id','3');
querySetCell(properties,'name','Harry');
queryAddRow(properties);
querySetCell(properties,'id','4');
querySetCell(properties,'name','Sally');
</cfscript>



<cfsavecontent variable="onLoad">
grdProps.setFocus();
grdProps.setSelectedIndex(0);
</cfsavecontent>

<cfsavecontent variable="binding">
{(trigger.text != '') ? trigger.dispatchEvent({type:'change'}) : 'init'}
</cfsavecontent>


<cfform name="mainform" format="flash" method="post" width="400"
onchange="#onLoad#" bind="#binding#">
<cfformgroup type="panel">
<cfformgroup type="horizontal">
<cfformgroup type="vbox">
<cfgrid format="flash" query="properties" name="grdProps" width="240"
rowheaders="no">
<cfgridcolumn name="name" header="Name">
</cfgrid>
<cfinput type="text" visible="false" height='0' width="0" name="trigger"
value="init" onchange="#onLoad#" bind="#binding#">
</cfformgroup>
</cfformgroup>
</cfformgroup>
</cfform>

pope on acid
7/4/2005 11:01:41 AM
This works, thx !!!

But can you give us a few words of what is the invisible textbox and the second cfsavecontent-tag exactly does, please?

JadeBlue
7/5/2005 12:00:00 AM
The text input and the code in the cfsavecontent tag are a necessary workaround
if you want to select the first item on form load because flash forms do not
have an onload attribute.
You can read more about that at
http://www.asfusion.com/blog/entry/onload-event-coldfusion-flash-forms-2

Laura
AddThis Social Bookmark Button