all groups > coldfusion flash integration > december 2005 >
You're in the

coldfusion flash integration

group:

cfgrid auto highlight top entry?


cfgrid auto highlight top entry? KevynJ
12/16/2005 8:47:20 PM
coldfusion flash integration:
Hello,

I am wondering if there is a wy for cfgrid to automatically highlight the an entry as selected when the form loads in flash?

Thanks in advance!

Re: cfgrid auto highlight top entry? endymion96
12/23/2005 4:21:54 PM
Not sure exactly how but it seems you would need to setup an "onload" function
in your cfform which sets up a "modelChanged" event for your grid. When the
grid first loads with data it will fire the "modelChanged" event and you can
take it from there.
Re: cfgrid auto highlight top entry? bradwood.com
1/4/2006 12:28:22 AM
http://www.asfusion.com/blog/entry/knowing-when-the-cfform-data-arrives
explains this process quite well.

<cfform name="myForm" format="flash" onload="onFormLoad()">
<cfformitem type="script">
<!--- onload function --->
function onFormLoad(){
var listener:Object = {};

//put the controls in scope to avoid calling _root
var contactList:mx.controls.DataGrid = contactList;

listener.modelChanged = function(evt):Void {
alert('Data loaded... select first item');
<!--- remove listener, so that we are not longer notified of model
changes --->
contactList.removeEventListener('modelChanged',listener);
<!--- select first item --->
if (contactList.dataProvider.length){
contactList.selectedIndex = 0;
}
}

contactList.addEventListener('modelChanged',listener);
}
</cfformitem>
<cfgrid name="contactList" query="contactsQuery" rowheaders="false">
<cfgridcolumn name="name" header="Employee Name">
<cfgridcolumn name="gender" header="Gender">
<cfgridcolumn name="age" header="Age">
</cfgrid>
</cfform>

Note, you need MX the 7.0.1 patch to use the cfformitem tag with type="script"

~Brad
AddThis Social Bookmark Button