|
|
hi can anyone enlighten me as to how to pass data to a cfselect from a cfgrid
i am using a listner function so that the grid can populate form controlswhen
a row is selected
i use bindings on cfinputs so no problem there
how do u populate a cfselect drop down with data from a grid
and then how woul i also display query results from another query as a second
option
lost
yes i dont konw much as
realyy apprecitae your help
<cfform action="p2action.cfm" method="post" name="addressBook" format="flash"
height="680" width="100%" style="themeColor:##2B52FF;"onload="onFormLoad()">
<!--- filter script --->
<cfformitem type="script"> function applyFilter( term:String,
grid:mx.controls.DataGrid, columns:Array ):Void {
var filterTerm:String = term.toString().toLowerCase();
if(filterTerm.length > 0) {
if(_global.unfilteredData[grid.id] == undefined){
if (_global.unfilteredData == undefined){
_global.unfilteredData = {};
}
_global.unfilteredData[grid.id] = grid.dataProvider.slice(0);
}
var filteredData:Array = [];
for(var i = 0; i< _global.unfilteredData[grid.id].length; i++)
{
var item:Object = _global.unfilteredData[grid.id][i];
var added:Boolean = false;
for(var j = 0; j< columns.length; j++){
if(!added){
var value:String = item[columns[j]].toString().toLowerCase();
if(value.indexOf(filterTerm) != -1) {
filteredData.push(item);
added = true;
}
}
else {
break;
}
}
}
grid.dataProvider = filteredData;
}
else {
if(_global.unfilteredData[grid.id] != undefined)
grid.dataProvider = _global.unfilteredData[grid.id];
}
} </cfformitem>
<!--- end of filter script --->
<!--- select first item --->
<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);
}
<!--- helper function to select items in a dropdown --->
public function selectOption(select: mx.controls.ComboBox,
optionToSelect:String):Void{
//go through every record to find the right one
for (var i:Number = 0; i< select.length; i++) {
if (select.getItemAt([i]).data == optionToSelect){
select.selectedIndex = i;
break;
}
}
} </cfformitem>
<!--- end select first item --->
<!--- firstpanel on left side --->
<cfformgroup type="hbox" height="600">
<cfformgroup type="panel" width="220" label="Prospective Buyers"
style="panelBorderStyle:'roundCorners'; themeColor:##FE7E00;
headerColors:##F2CB2A, ##FFE57A; backgroundColor:##FFE57A;">
<cfformgroup type="panel" label="Search in custom column">
<cfformgroup type="horizontal">
<cfinput type="text" name="secondTerm"
onchange="applyFilter(secondTerm.text,contactList,[column.selectedItem.data])"
width="90" label="Filter by:">
<cfselect name="column" label="in:"
onchange="secondTerm.text=''" width="90">
<option value="fname">First Name</option>
<option value="lname">Last Name</option>
</cfselect>
</cfformgroup>
</cfformgroup>
<cfgrid name="contactList" height="400" query="clients"
appendkey="yes" griddataalign="left" gridlines="yes" rowheaders="no"
colheaderalign="left" selectmode="browse" enabled="yes" visible="yes"
format="flash" autowidth="true">
<cfgridcolumn name="fname" header="First Name">
<cfgridcolumn name="lname" header="Last Name">
<!--- <cfgridcolumn name="email" header="Email"> --->
</cfgrid>
<!--- add contact button selects editShow checkbox and resets
the form --->
<cfinput type="button" name="addContact2"
onClick="getURL('showq.cfm?clientref='+contactList.selectedItem.clientref,'_b
lank');" value="Match Property"/>
<!--- add contact button selects editShow checkbox and resets
the form --->
<cfinput type="button" name="addContact"
onClick="contactList.selectedIndex = undefined;
resetForm();
editShow.selected = true;" value="Add Contact" style=" borderThickness:1;"/>
</cfformgroup>
<!--- set the form to have tabs --->
<cfformgroup type="tabnavigator">
<!--- set the page value - give the tab a label --->
<cfformgroup type="page" label="EDIT DETAILS">
<!--- Set the form alignment --->
<cfformgroup type="horizontal">
<!--- visible and height bounded to editShow checkbox --->
<cfformgroup type="panel" visible="YES" height="540"
label="Edit"
style="panelBorderStyle:'roundCorners'; backgroundColor:##E9EAFF;
headerColors:##CED7FF, ##D9E0FF;">
<cfformgroup type="hbox">
<cfformgroup type="hbox">
<cfinput type="text" name="fname" label="First Name:"
bind="{contactList.selectedItem.fname}" required="true" validate="noblanks"
message="First Name is required" />
<cfinput type="text" name="lname" label="Last Name:"
bind="{contactList.selectedItem.lname}" required="true" validate="noblanks"
message="Last name is required"/>
<cfinput type="text" name="email" label="Email:"
bind="{contactList.selectedItem.email}" message="A valid email address is
required" required="true" validate="email" />
<cfinput type="text" name="tel" label="Phone:"
bind="{contactList.selectedItem.tel}" mask="99999-999999" />
<cfinput type="text" name="office" label="Office:"
bind="{contactList.selectedItem.office}" mask="99999-999999" />
<cfinput type="text" name="mobile" label="Mobile:"
bind="{contactList.selectedItem.mobile}" mask="99999-999999"/>
<cfinput type="text" name="photo" label="Photo:"
bind="{contactList.selectedItem.photo}" />
<!--- new items --->
<cfinput type="text" name="typereq" label="Typereq:"
bind="{contactList.selectedItem.typereq}" />
<cfinput type="text" name="minbedsreq" label="Min Beds req:"
bind="{contactList.selectedItem.minbedsreq}" />
<cfinput type="text" name="minreq" label="Min Price req:£"
bind="{contactList.selectedItem.minreq}" />
<cfinput type="text" name="maxreq" label="Max Price req:£"
bind="{contactList.selectedItem.maxreq}" />
<!--- <cfselect enabled="yes" name="locationreq" label="Location Req"
message="State is required" multiple="no" query="county"
bind="{contactlist.selectedItem.locationreq)" display="towns"
queryposition="below"><option>#towns#</option>
</cfselect> ---><cfselect name="locationreq"
label="{contactList.selectedItem.locationreq}" required="Yes" message="State
is required" bind="{contactList.selectedItem.locationreq}">
<option></option>
</cfselect>
<!--- <cfinput type="text" name="locationreq" label="Location
req: " bind="{contactList.selectedItem.locationreq}" /> --->
<cfinput type="text" name="special" label="Special req:"
bind="{contactList.selectedItem.special}" />
<!--- end new items --->
<cfinput type="hidden" name="clientref"
bind="{contactList.selectedItem.clientref}" />
<cfinput type="hidden" name="deleteContact" value="notDeleted"
/>
</cfformgroup>
<cfformgroup type="hbox">
<cfinput type="text" name="address1" label="Address:"
bind="{contactList.selectedItem.address1}" />
<cfinput type="text" name="address2" label="Address2:"
bind="{contactList.selectedItem.address2}" />
<cfinput type="text" name="town" label="Town:"
bind="{contactList.selectedItem.town}" />
<cfinput type="text" name="postcode" label="Post code:"
bind="{contactList.selectedItem.postcode}" validate="zipcode"/>
<cfinput type="text" name="county" label="County:"
bind="{contactList.selectedItem.county}" />
<cfinput type="text" name="propertytosell" label="Property To
Sell:" bind="{contactList.selectedItem.propertytosell}" />
<cfinput type="text" name="mort" label="Mortgage req:"
bind="{contactList.selectedItem.mort}" />
<cfinput type="text" name="valuationreq" label="Valuation req:"
bind="{contactList.selectedItem.valuationreq}" />
</cfformgroup>
</cfformgroup>
<cfformgroup type="vertical"
|
|