Skip to main content
Participant
August 30, 2006
Question

Update multiple cfgrids using flash remoting

  • August 30, 2006
  • 1 reply
  • 365 views
I'm working on an application to allow people to enter their paid time off and because of the specs of the project I need to have a cfgrid for each month, so 12 grids. I have all of the remoting working if I hard code the grid names, but I also am able to pass the grid name through the cfcs and display it via an alert on the response handlers. What I cannot get to work is to create a variable of type mx.controls.DataGrid and assign the grid name to it. I'm assuming this is because the grid name is a string and not a data grid object.

Does anyone know how to dynamically reference a data grids in ActionScript? I'll post the code below.

<!--- handle update response - This code does not update the grid. The value of results.gridName is 'AugPTO' --->
responseHandler.updatePTO_Result = function ( results:Object):Void {

if (results.status) {
var item:Object = results.item;
alert(results.gridName);
var grid:mx.controls.DataGrid = results.gridName;
var index:Number = _root.findItem(grid,'PTOID',results.PTOID);
grid.replaceItemAt(index,item);
}
mx.managers.CursorManager.removeBusyCursor();

alert(results.message);
}

<!--- handle update response - This code does update the grid. AugPTO is the name of the grid for August. --->
responseHandler.updatePTO_Result = function ( results:Object):Void {

if (results.status) {
var item:Object = results.item;
var index:Number = _root.findItem(AugPTO,'PTOID',results.PTOID);
AugPTO.replaceItemAt(index,item);
}
mx.managers.CursorManager.removeBusyCursor();

alert(results.message);
}

Any ideas?

Thanks,
Dan

p.s. I've followed to Real Estate example from CFDJ to get this far, so if you are familiar with that app mine is pretty similar.
    This topic has been closed for replies.

    1 reply

    Participant
    August 31, 2006
    Couldn't you pass the grid name as a parameter when calling your AS function from within the form, then bind the name to variable. Something like this:

    function bindGrid(gridNameToUpd)() {
    var strDomain = 'mydomainname/flashservices/gateway/';
    var connection:mx.remoting.Connection = mx.remoting.NetServices.createGatewayConnection(strDomain);
    var myService:mx.remoting.NetServiceProxy;
    var grid2Upd = gridNameToUpd;
    var responseHandler = "";
    responseHandler.onResult = function( results: Object ):Void {
    grid2Upd.DataProvider = results;
    }

    responseHandler.onStatus = function( stat: Object ):Void {
    alert("Error while calling cfc:" + stat.description);
    }

    myService = connection.getService("cfc.cfcName", responseHandler );
    myService.cfcName(params);
    }