Groups | Blog | Home
all groups > coldfusion flash integration > october 2007 >

coldfusion flash integration : Filter CFgrid with Flash Remoting (Problem)


nightkiller211
10/18/2007 6:06:10 PM
:confused;

I can't seem to figure out why the filter as you type feature isn't working.
When I type some text in the text-box it clears the grid. I can't get it to
work with Flash Remoting.



<cfsilent>
<!--- make an empty query to populate the grid with no records --->
<cfset memberList = queryNew("CustName,TechCode") />
</cfsilent>

<
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Populating a cfgrid with Flash Remoting</title>
</head>

<body>
<cfform name="myform" height="550" width="499" format="Flash" timeout="300"
onload="onFormLoad()">
<cfformitem type="script">
function onFormLoad(){
var listener:Object = {};

//put the controls in scope to avoid calling _root

var getData:Function = getData;
var search:Function = search;
var whereismytech:mx.controls.DataGrid = whereismytech;


listener.modelChanged = function(evt):Void {
alert('Data loaded... clear datagrid until department is selected');

whereismytech.removeEventListener('modelChanged',listener);

<!--- empty search, should return no value --->

search('',whereismytech,[]);
}

listener.search = search;

getData();

whereismytech.addEventListener('modelChanged',listener);
}

function getData():Void{
<cfoutput>
//create connection

var connection:mx.remoting.Connection =
mx.remoting.NetServices.createGatewayConnection(
"http://#cgi.HTTP_HOST#/flashservices/gateway/";);
//declare service

var myService:mx.remoting.NetServiceProxy;
</cfoutput>

var responseHandler:Object = {};

//put the controls in scope to avoid calling _root

var whereismytech:mx.controls.DataGrid = whereismytech;


responseHandler.onResult = function( results: Object ):Void {
//when results are back, populate the cfgrid
whereismytech.dataProvider = results;

mx.managers.CursorManager.removeBusyCursor();
}

responseHandler.onStatus = function( stat: Object ):Void {
//if there is any error, show an alert
alert("Error while calling cfc:" + stat.description);
mx.managers.CursorManager.removeBusyCursor();
}

//get service, make sure you write the correct path
myService =
connection.getService("/Working-Remoting/xxxx/flashRemotingResponder",
responseHandler );
mx.managers.CursorManager.setBusyCursor();
//make call

myService.getMembers();
}

<!--- search function --->
function search( term:String, grid:mx.controls.DataGrid, columns:Array ):Void {

var filterTerm:String = term.toString().toLowerCase();

if(_global.unfilteredData[whereismytech.id] == undefined){
if (_global.unfilteredData == undefined){
_global.unfilteredData = {};
}
_global.unfilteredData[whereismytech.id] = grid.dataProvider.slice(0);
}

if(filterTerm.length > 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>
<cfinput type="text" name="secondTerm"
onchange="search(secondTerm.text,whereismytech,[column.selectedItem.data])"
width="90" label="Filter by:">
<cfselect name="column" label="in:" onchange="secondTerm.text=''"
width="90">
<option value="CustName">CustName</option>
<option value="Job_ID">Job ID</option>
<option value="Supvsr">Supvsr</option>
<option value="CustAddr">CustAddr</option>
</cfselect>

<cfgrid name="whereismytech" query="memberList" height="200"
rowheaders="false" >
<CFGRIDCOLUMN NAME="TechCode" header="Tech Code">
<CFGRIDCOLUMN NAME="CustName" HEADER="CustName">

</cfgrid>
<cfinput type="button" name="getValues" value="Populate data grid" >
</cfform>
</body>
</html>
cfhalf-life
10/23/2007 9:21:51 PM
isn't this supposed to be in dot notation instead

myService = connection.getService("/Working-Remoting/xxxx/flashRemotingResponder", responseHandler );

AddThis Social Bookmark Button