Our Blog

As a follow up of my last post, I made an example on how to populate a cfgrid with Flash Remoting.
The basic difference is that now the ColdFusion component returns a query instead of a string. The important part in the ActionScript code is how we set the data to the datagrid. To show the effect, I create a cfgrid and populate it with an empty query, so that when I call the component, I can see the data loaded.

The main change is in the function that handles the response:

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

Note: If you want the dataProvider to be an array (like it is when you load the grid normally), use: contactList.dataProvider = results.items; This will make it work if you are using our "Filtering as you type" code.

The number of records returned can be found at results.length. You could notify the user that no records were found.

responseHandler.onResult = function( results: Object ):Void {
   //when results are back, populate the cfgrid
   contactList.dataProvider = results;
   if (!results.length){
      alert('No records found');
   }
}

The complete code:

<!--- make an empty query to populate the grid with no records --->
<cfset memberlist="queryNew("id,name,age,gender")">
<cfsavecontent variable="getData">
   //create connection
   var connection:mx.remoting.Connection =
      mx.remoting.NetServices.createGatewayConnection(
         "http://www.example.com/flashservices/gateway/");
   //declare service
   var myService:mx.remoting.NetServiceProxy;

   var responseHandler = {};

   //put the controls in scope to avoid calling _root
   var contactList = contactList;
   
   responseHandler.onResult = function( results: Object ):Void {
      //when results are back, populate the cfgrid
      contactList.dataProvider = results;
   }

   //function that receives any error that may have occurred during the call

   responseHandler.onStatus = function( stat: Object ):Void {
      //if there is any error, show an alert

      alert("Error while calling cfc:" + stat.description);
   }
      
   //get service

   myService = connection.getService("blog.examples.flashRemotingResponder", responseHandler );
   //make call

   myService.getMembers();
</cfsavecontent>
</cfset>

The form only contains a cfgrid and a button that triggers the call.

<cfform name="myform" format="Flash">
   <cfgrid name="contactList" query="memberList">
      <cfgridcolumn name="name" header="Name">
      <cfgridcolumn name="age" header="Age">
      <cfgridcolumn name="gender" header="Gender">
   </cfgridcolumn>
   <cfinput type="button" name="getValues" value="Populate data grid" onclick="#getData#">
</cfinput>
</cfgridcolumn></cfgridcolumn></cfgrid></cfform>

A live example
Download the source

Laura

Laura

148 Comments

  1. CarlosM()

    CarlosM()

    Could you please help me out?

    I as able to populate the grid with my own query but, how do I pass an argument in a “text box” using remoting to the cfc to return a selective query to populate the grid?

    Your insight is much appreciated!
  2. Hi,
    In this example (http://www.asfusion.com/blog/entry/remoting-for-coldfusion-flash-forms ) we show you how to pass an argument to the cfc.
  3. CarlosM()

    CarlosM()

    Sorry, I'm new to AS.
    It didn't occur to me that MyService.getDate(mask.text) is the string passed...:0 I had to take little bits.

    Thank You
  4. Paul Roe

    Paul Roe

    Is there any way to do two seperate calls to flash remoting with one event.

    For example I have the following code:

    <cfinput type="Button" name="asdf" value="asdf" onclick="#getData#" />

    How can I call two functions in my cfc and work with them in action script. Following your example I am able to populate the cf grid with data based on the value of the cfinput but I also want to get back data from another function at the same time to display text that is not in the grid. How would I go about doing this? Also is there anything like onBlur for a <cfinput type="text" /> field?
  5. AndyC
    Hi there,
    I have copied across your cfgrid example and set up the remoting and service so that the example works fine on my site
    So fa so good
    However, when I attempt to adapt the cfgrid-remoting code to my requirements I hit the error

    Attribute validation error for tag CFGrid.
    The value of the attribute Query, which is currently "q_getPlayerList", is invalid.

    The function I am calling is named getPlayerList in a cfc named mlbPlayer in directory mlb
    and I call it thus

    myService = connection.getService("mlc.mlbPlayer", responseHandler );
       
       myService.getPlayerList();

    The function with a simplified query looks like this

    <cffunction name="getPlayerList" access="remote" returnType="query">
    <cfargument name="name" type="string" required="true" default="Rodr">    
    <CFQUERY NAME="q_getPlayerList" Datasource="mlbSQL">

    SELECT nameFull
    FROM MasterPlayers

    </CFQUERY>

    <cfreturn q_getPlayerList>
    </cffunction>

    Any suggestions of where I am in error
    Cheers
  6. Laura
    Andy,
    It seems that you don't have a query with that name in that page. You at least have to have an empty (or not empty) query to tell cfgrid what to populate with, even if you later oeverwrite that data with remoting. Check the first line of the code in the post:
    <cfset memberList = queryNew("id,name,age,gender") />
    Change that to
    <cfset q_getPlayerList = queryNew("nameFull")/>

    or simply call your own function (the grid will be loaded with data, not empty)
    <cfset q_getPlayerList = yourInstatiatedComponent.getPlayerList() />

    Hope that helps
  7. AndyC
    Laura
    Thanks that was a great help

    One quirk I am getting
    I am using a text input to obtain a list of baseball players
    <cfinput type="text" name="player" width = "150" label="Enter Name" onChange="#getPlayerList#"/>

    In <cfsavecontent variable="getPlayerList">
    I call
    myService.getPlayerList(player.text);

    where getPlayerList has a query

    SELECT TOP 100 PERCENT MasterPlayers.playerID, careerSpan.nameFirst, careerSpan.nameLast, careerSpan.startyear,
    careerSpan.endyear, (careerSpan.nameFirst+' '+careerSpan.nameLast) as nameFull
    FROM MasterPlayers INNER JOIN
    careerSpan ON MasterPlayers.playerID = careerSpan.playerID
    WHERE (careerSpan.nameLast LIKE N'#name#%') OR (careerSpan.nameFirst LIKE N'#name#%')
    ORDER BY careerSpan.nameLast, careerSpan.nameFirst

    The grid I put the results in shows up the correct data ultimately but precedes this with a wider range of similar, but incorrect, names. This is unlike when i call the query in html or pure flash
    Check out the rough version at
    http://www.majorleaguecharts.com/mlc/mycfgrid-remoting.cfm

    Any hep appreciated
  8. AndyC
    I would also like to echo Paul's request re accessing two or more functions via a single onClick, onChange etc
    I see this was also asked a week or so ago in the CFDJ article entry. Any chance we could have a definitive answer on whether this is possible in any way
    Cheers
  9. Steve Walker
    Does anyone have an example of a grid value being passed to a CFC and populating another grid (e.g. orders -&gt; order details)?

    I would also like to cast my vote for a multi-function example.
  10. AndyC
    Steve
    It's in a v rough format and I'm hoping for some answers myself but check out
    http://www.majorleaguecharts.com/mlc/mycfgrid-remoting.cfm
    enter a players last name and the left hand grid populates (oddly)
    Click on one of the names and the righthand grid is populated with details
    I dont have the code in front of me but just put an onchange=#getnewgrid# into cfgrid and do a duplicate of the cfsavecontent section (geData i believe) for your original grid just changing references as required
  11. Steve Walker
    Andy,

    I took a look at your example (very nice) and I am not sure that I understand your problem. Based on the widcards in your Like condition it is working as it should (except for two empty records when I type &quot;smi&quot;). I did notice that it takes a few seconds for the grid to finish re-populating when you change names.

    What was the syntax you used for passing the playerID to the component to populate the second grid?


    Steve
  12. Steve Walker
    So I figured out how to pass the variable (myService.ComponentName(grid1.dataProvider[grid1.selectedIndex]['value_column']);), but have a new problem. One of the fields that is returned is a date field, but the mask is not working. With the mask defined I get the text mm/dd/yyyy, with it undefined I get Thu Jan 13 02:00:00 GMT-0500 2005.
  13. I would like to return the recordcount of my query to a field or cfformitem in my flash form but i can't get it to work. Do you have any ideas ?
  14. Steve Walker
    I used:

    <cfformitem type="html" width="400"><cfoutput>#QueryName.RecordCount# Item(s) Listed</cfoutput></cfformitem>
  15. Neil Bailey
    I think that tying remoting calls into cf flash forms is brilliant - and the grid is the PERFECT example of this.

    However, I am having an issue - I dunno if its ME, or a limitaion that I need to work around. I have a grid w/ three columns, ID, Name and Email - the ID coumn is not displayed. When I get the return value back from the CFC, the Name and Email columns are fine, but the ID column doesn't seem to be being populated (I have ANOTHER remoting call where I am passing the ID from the selected item in the grid to another CFC, and I am getting an error returned that says the ID field is not being passed in). The ID field is DEFINITELY available BEFORE the data in the grid is &quot;filtered&quot;, but DEFINITELY not afterwards...

    Any ideas would be MUCH appreciated......
  16. Hi Steve,
    The problem with the mask is a bug in ColdFusion. They will fix that in the next release, Merrimack.
  17. Neil,
    Check your case in the column name, remember that it must be exactly the same as it comes form the database. (do not trust the case in cfdump)
  18. Nahuel
    Andy and Paul,
    You can do something like this onChange="#saveContent1##saveConten2#"
    in that way you'll have two responseHandlers that do different things when the data comes back.
  19. AndyC
    Nahuel
    Thanks. I have this working well now
    I would also like to include a cfchart in the cfform
    trying to adapt your remoting work and some of Ray Camden's on his blog - so far unsuccessfully
    Is this feasible?
    I could send you my work or post the code here - though it's a bit long
  20. Brendan Rehman

    Brendan Rehman

    It just not working for me. I dont get any error messages, non of the events fire... CFMX7 on RH Linux ES, Postgres 8 DB.

    Please help...

    <cfsilent>
       <cfset _listActiveFolders = queryNew("int_application_id,fk_application_id,vchar_vessel_id,vchar_application_status,date_application_date,vchar_dealer_taxpayer_id,vchar_application_type,int_active_folder_number,vchar_record_created_by,dttm_creation_date,fk_vessel_id,fk_dealer_entity_id_number,vchar_dealer_taxpayer_id") />\
       <cfsavecontent variable="GetActiveFolders">
       
          //alert("GETACTIVEFOLDERS1");
          var connection:mx.remoting.Connection =   mx.remoting.NetServices.createGatewayConnection("http://#cgi.HTTP_HOST#/flashservices/gateway/");
          var myService:mx.remoting.NetServiceProxy;
          var responseHandler = {};
       
          //put the controls in scope to avoid calling _root
          var ActiveFoldersGrid = ActiveFoldersGrid;
       
          responseHandler.onResult = function( results: Object ):Void
          {
             //when results are back, populate the cfgrid
             ActiveFoldersGrid.dataProvider = results;
          }
          
          //function that receives any error that may have occurred during the call
          responseHandler.onStatus = function( stat: Object ):Void
          {
             //if there is any error, show an alert
             alert("Error while calling cfc:" + stat.description);
          }
          
          //get service
          myService = connection.getService("com.pimsapplications", responseHandler );
          //make call
          myService.fncGetActiveApplications ("0","","IN PROGRESS");
          alert("GETACTIVEFOLDERS2 Function Called");
          
       </cfsavecontent>
    </cfsilent>
  21. Rick
    This has really helped me a lot, but now I am having the user edit the data in the grid and I have an update button. How do I pass the grid data to flash remoting so I can update the database?
  22. Laura
    Brendan,
    Are you putting the variable in your form in a button?
    &lt;cfinput type=&quot;button&quot; onclick=&quot;#GetActiveFolders#&quot; ....&gt;
  23. Laura
    Bob,
    If you want to know how many records were returned, you can get results.length. You can then write that in a text input or similar.
  24. Frank Gerritse

    Frank Gerritse

    Hi there,

    This example is working great, but can someone tell me why the mask attribute and display attribute in cfgridcolumn doesn't work when I populate a cfgrid with Flashremoting.

    <cfgrid name="autoList" query="Auto1" rowheaders="true" width="820" height="350" gridlines="no" colheaderbold="yes" colheaderalign="center" >

    <cfgridcolumn name="AutoID" header="AutoID" width="80" display="no" />
    <cfgridcolumn name="Kenteken" header="Kenteken" width="80" />
    <cfgridcolumn name="Automerk_omschrijving" header="Automerk" />
    <cfgridcolumn name="Autotype" header="Autotype" />
    <cfgridcolumn name="Brandstof_omschrijving" header="Brandstof" />
    <cfgridcolumn name="APKDatum" header="APK" mask="DD-MM-YYYY" />
    <cfgridcolumn name="Tankpasnum" header="Tankpas num" />
    <cfgridcolumn name="Tankpas" header="Tankpas pin" />
    <cfgridcolumn name="naam" header="Werknemer" />
    <cfgridcolumn name="Achternaam" header="Achternaam" display="no" />
    </cfgrid>
    <cfinput type="button" name="getValues" value="Populate data grid" onClick="#getAutos#">
  25. David Brown

    David Brown

    First let me say thank you for this web site. I have created several forms that work great thanks to you guys here. All with flash remoting.

    Problem: I grid on the flash form with data from a query on the page. I then make changes to the data in the grid and send the grid.dataProvider back to a cfc to update the database(works great). I then click a button to call another cfc for a new query to send to the grid. This works too. I then edit that data and click the button to send the data back to the cfc to update the db. But I get an error: &quot;Unsupported type found in stream&quot;. So it seems that I can have grid load it with data from a query on the page, edit the data in the grid, send the grid to a cfc and update my db. But if you popluate the grid with flash remoting and try to send the data to a cfc you get an error. Any ideas how to fix this?
  26. Laura
    Frank,
    the grid mask has a bug. I've always had trouble with it. Fortunately, I heard that it has been fixed in the cf updater.

    David,
    Flash remoting supports sending queries to Flash but not sending RecordSets (the Flash version of a query) to the server, and that it's why you are getting the &quot;Unsupported type....&quot; error.
    It seems that when the cfgrid gets populated the regular way, it doesn't set the dataprovider directly but massages the data so that it is not a recordset but an Array, so are able to send that back to CF. You will have to construct the array yourself before sending it to cf.
  27. andy
    Is flash remoting the only way to change cfgid data from text input without reloading / reinitializing the page?
  28. David D Brown

    David D Brown

    Thanks for the info. How do I convert the gridname.dataprovider to an array.

    I think I would then send the array to the cfc as an type array. Then loop over the array and insert into the db. right?
  29. Laura
    David,
    I think this will solve the array problem. To have an array just like the one you get when loading data into the grid normally, set the dataprovider like this:
    gridname.dataProvider = results.items;

    Andy,
    I do not really understand your question, what do you mean by changing the grid data from text imput?
  30. AndyC
    Laura
    Not that I'm the same Andy as you were replying too, but do you have an answer to the query I posed Nahuel on 14th Aug?
  31. Jeff
    Hi there,

    I'm trying to populate a cfgrid with Flash Remoting
    ( like http://www.asfusion.com/blog/entry/populating-a-cfgrid-with-flash-remoting )
    from a recordset with complex SQL(Oracle), but the grid create only white lines without data. However, trying with access database the same recordset it`s works fine.

    How i can to solve this?

  32. Hi Jeff,
    Check your column names because Flash is case sensitive. If you don't know what your columns your recordset has, in the result you can use getColumnNames() or columnNames to get the array with their names.
  33. Jeff
    I tried and the grid continues showing white lines without data. With mySQL and access
    (single sql), it works fine.
  34. Brent
    How would you populate the grind on load and not on the click of a button
  35. Jeff
    Nahuel and Laura, I am having a heck of time getting flash-remoting working with cf mx 7. I have just wiped my machine and done a fresh install (stand-alone). Once I completed the install of 7 I am attempting to run your grid with remoting example. I continually get the error stating &quot;Error while calling cfc: Service flashRemotingResponder not found.&quot; Please point me in the right direction. Thanks so much.
  36. Neil Bailey
    Jeff,

    That error message that you're getting there (believe me, I've gotten it) means that everything on the remoting side is good, its attempting to make the call, and it can't find the CFC you've specified in the location you're telling it to look.

    I keep all of my CFCs in a folder named components. So when I call a CFC from a cfform in a remoting call, I call components.someCFCName

    Hope this helps. If not, you're in the right place. These guys are......haha fairly intelligent...
  37. Jeff
    Neil/asfusion... DOH!!!!! how simple, how stupid of me... Though a bit confusing 8-). Alright for all the newbs. U must set up iis or whatever webserver u are using properly. Steps I used to resolve. (very easy)

    1. Create a virtual directory call asfusion under the site (be sure this points to the directory where the example files were unzipped i.e. c:\wwwtest\asfusion.

    2. Next go to line 28 which should read &lt;i&gt;myService = connection.getService(&quot;flashRemotingResponder&quot;, responseHandler ); &lt;/i&gt; and change it to &lt;i&gt;myService = connection.getService(&quot;asfusion.flashRemotingResponder&quot;, responseHandler );&lt;/i&gt;
    Notice the &quot;asfusion.&quot; added to reference the cfc properly.

    3. Lastly run your example.

    I know my description is very elementary, but when you're coding with blinders on at time you tend miss the extremely obvious. Thank you all.

  38. John
    In the responseHandler.onResult
    is there an alternative to
    contactList.dataProvider = results;

    when I submit the form after flash remoting
    cfgird array is always empty.

    Here is another thing I tried.
    My grid starts out with some data.
    Then when they click a button I use flash remoting to repopulate the data.
    When I click on the submit button and submit the form and do a cfdump of the form variables
    it shows me an array of the changes I made to the cfgrid prior to the flash remoting
    but not after.


    Thanks

    John
  39. Laura
    Jeff,
    You can also use a normal directory, writing the correct path from the root to the component. Both actual directories or virtual directories work.
    Check &quot;A couple of notes on Remoting&quot; at the bottom of this post:
    http://www.asfusion.com/blog/entry/remoting-for-coldfusion-flash-forms

    John,
    I wouldn't recommend mixing the Flash Remoting approach with the normal submit approach. The only solution I can think of right now is to do the following instead of dataProvider = results:

    contactList.dataProvider.removeAll();
    for (var i = 0; i &lt; results.length; i++){
       contactList.dataProvider.addItem(results.getItemAt(i));
    }

    It will be a little slow if you have lots of items.
    Also, update will work fine, but to make insert work, you will need to write your own button (instead of using insert=&quot;true&quot;) and set onclick=&quot;GridData.insertRow(contactList);&quot;
    The same should be true for delete, but I am not sure why delete is not working with GridData.deleteRow(contactList); though.
  40. Critter
    if i run the above example from c:\inetpub\wwwroot\projects\pets\

    and use projects.pets.assets.com.flashRemotingResponder

    as the path.. i get nothing.. or a null (when attempting the date mask example)

    if i place flashRemoteResponder.cfc into the root of my webserver &quot;/&quot; and call it via &quot;flashRemotingResponder&quot; then it works fine.. any suggestions? i'm lost.
  41. Laura
    Critter,
    Do you get an alert &quot;Error while calling cfc:&quot;...
    do the folder pets have assets/com folder?
    Are you able to browse
    /projects/pets/assets/com/flashRemotingResponder.cfc?method=getDate
    ?
  42. Critter
    No error shown.. when i do the get date example from this site.. i just get a &quot;null&quot; that shows in the textfield. i can access the cfc and that method from other coldfusion templates.. it's just like the flash remoting won't hit anything unless it is in the root.
  43. Jeff
    Critter,
    I'm guessing you're using IIS as your web server. Go to your virt dir or dir in IIS and go to properties. Be sure the Execute Permissions are set to Scripts and Executables. I noticed the root is set to this by default but created virt dirs or added dirs default to scripts only. Hope this fixes it for you. Good luck.
  44. Critter
    I have one server running IIS and one running on Apache. I get the same with both. the flash form is obviously finding the cfc, because if i change the directory structure in the .cfm then it will throw an error saying it cannot find the cfc.. otherwise.. with the grid example it does nothing.. with the date mask one... it just outputs &quot;null&quot; :(
  45. Critter
    Ok.. well i found what was causing the problem, although, i do not understand why.. and definitely need to look into it further. when running the examples in an application i alreay have.. the flash remoting returns a &quot;null&quot; when i have an Application.cfc in the application. removing the Application.cfc causes the flash remoting to work as expected... *sigh*
  46. Critter
    not sure what is happening, but if i have:

    <cffunction name="onRequest" returnType="void">
    <cfargument name="thePage" type="string" required="true">
    <cfinclude template="#arguments.thePage#">
    </cffunction>

    in my application.cfc flash remoting returns a null.... remove this function.. and it works fine..
  47. Critter
    ray posted a &quot;fix&quot; to his blog about the onRequest function in the application.cfc. so i have that sorted.

    one question. i have a grid that is populated via a regular query. the onclick of a row uses flash remoting and returns a struct
    if i do
    var q = results.QUERY;
    alert(q.getLength()); // returns 6;
    alert(q.getColumnNames()); returns a list of the columns.

    but when i attempt to attach the query to a second grid (lstPetFeedings.dataProvider = q;) i get nothing.. and even alert(q.getItemsAt(0).feedId); returns a blank...

    is there any way to dump the object that is returned? like a cfdump?

    thanks in advance.. Crit
  48. Laura
    Critter,
    Regarding the problem of the onRequest method:
    A Remoting (or web service) call is different than a normal template call. In those cases, you are calling a method on a component directly. It wouldn't make sense to &quot;include&quot; the &quot;page&quot;, in which case it is a component, to make the method call on it. That goes for any other output that you may do in that method, as it will also make it fail.

    Although I don't see your complete code, I think this is your second problem: first, to get the first item the syntax is: q.getItemAt(0), not getItemsAt(0). lsPetFeedings grid is probably not in scope when you try to assign its dataProvider. You can put it into scope by adding var lsPetFeedings = lsPetFeedings; before the onResult function declaration.

    Hope that helps
  49. Happy Critter
    /me kicks myself. repeatedly!!

    i did catch the getItemAt issue.. /and/ setting the var lsPetFeedings = lsPetFeedings did sort that issue of nothing happening with the grid.

    many thanks!
  50. Chris
    Hi there,

    populating the grid works like a charm, but, I have an issue with fields that I bind to the grid... I load the grid with query data in an onLoad() event. Next, I have a couple of text fields that use the bind attribute to display some values from a selected row.

    When I load the page, the input field displays &quot;undefined&quot;, until a row is selected. Apparently
    the grid.selectedItem is undefined, until the grid loads and a row is selected. Is there a way around this, without having to set each field manually in an onChange() event of the grid?

    Thank you,

    Chris

  51. Laura
    Chris,
    use {(myGrid.selectedItem!=undefined)? mygrid.selectedItem.myColumn : ''}

    you can replace '' by a default if you want.
  52. Chris
    Laura,

    that didn't work for me either... still showed &quot;undefined&quot;. Then I used value=&quot;&quot; instead of the bind attribute, and still got &quot;undefined&quot;... then I realized that a value of &quot;&quot; is regarded as, well, undefined. Now I initially set a blank in the IIF construct and it displays properly.

    I am using CF 7.01 on Windows (hotfix applied). Can anyone confirm this behaviour of not accepting empty string values?

    Thank you,

    Chris
  53. Melissa

    Melissa

    I am new to using Flash Remoting with CFForms. I am using the real estate example to go by, which I think is awesome. I can call the cfc and populate a grid. The one thing I cannot figure out is how to call a CFC when a row is clicked in the grid. Thanks.
  54. Chris
    Melissa,

    in the <cfgrid> tag, use the onChange-Attribute to specify whatever you want to be executed when a row is clicked. With CF7 you can use functions that you put in <cfitem type="script"> blocks. With CF6 you need to go the <cfsavecontent> way:

    CF7:
    <cfgrid name="mygrid"... onChange="myFunc()">
    <cfformitem type="script">
    function myFunc()
    {
    ... do other things here ...
    myService.callMethod();
    }
    </cfformitem>

    CF6:

    <cfsavecontent variable="callFunc">
    ... do other things here ...
    myService.callMethod()
    </cfsavecontent>

    <cfgrid name="myGrid" ... onChange="#callFunc#">

    Most likely you will have to put the service into _root or _global context to get it working.

    If you want to specify separate result handlers for each method call, name them
    responseHandler.MethodName_Result

    Both the method name and the "_Result" are case sensitive.

    HTH,

    Chris
  55. Chris
    Urgent call for help!!

    I built my form and am almost done... it's quite complex and uses a lot of AS. (AS and CFML are about 1100 lines of code, not counting the CFC that queries the database).

    Now with the final changes (code reorganisation and inline comments) I suddenly hit the 32K barrier and get the error following msg:

    &quot;Branch between 40461 and 73233 around line 0 exceeds 32K span. If possible, please refactor this component.&quot;

    I tried to include the &lt;cfformitem&gt; tags that contain the AS and I also tried to put all the AS code into .as files and use #include. Still I get the same error.

    Is there any way to get around this? I must deliver this app in two days and Google has let me down this time. :-(((

    Thank you,

    Chris
  56. Hi Cris,
    You can try to set all your syles sheet via actionScript. Because Flex generates a lot of code for each style object.
    You can take a look at his post ( and its comments), to get the idea.
    http://www.asfusion.com/blog/entry/using-global-css-in-your-cfform
  57. Ryan F
    For some reason i'm getting this back from the responsehandler &quot;Error while calling cfc:Service threw an exception during method invocation: null&quot; I have tested my cfc's and they are known to work when invoked via cfm pages. Are there any pitfalls here i should be looking out for?

    The environtment is CF 7.01 running multiserver on iis6

    Best regards,

    Ryan
  58. Javier Julio
    Hey everyone,

    This examples work beautifully and has helped me a lot but I realize I have a specific problem. I need to update a field in the grid and I use editField but it does not work. For example:
    responseHandler.onResult = function( results: Object ):Void {
       mx.managers.CursorManager.removeBusyCursor();
       alert(&quot;&quot;+grdPaperData.selectedIndex+&quot; &quot;+radScore.selectedRadio.data);
       //when results return update cfgrid
       grdPaperData.editField(grdPaperData.selectedIndex,&quot;score&quot;,radScore.selectedRadio.data);
    }

    I output the 2 values I need to do an editField in an alert to make sure they exist and they do so I know I have the data I want. All I need to do is update the grid once its done with remoting. radScore is a radio button group. You can have a score of 1-5 that I let users pick from and when its changed I want to update that in my cfgrid. I have gotten it to work when there is no remoting involved at all, but once remoting comes into the picture it does not update the grid. :( Any idea why?? What am I doing wrong?? I have tried both dataProvider.editField and without the dataProvider and it does not update. I do not get any errors in the process, the flash form displays without any issues.
  59. Laura
    Ryan,
    The null error usually happens when there is an error in the cfc code (or templates that it calls). Even if it works when calling from other templates, check that you are passing the right parameters to verify that the behavior is the same.

    Javier,
    Since your alert shows the correct data, then it is not a scope problem. Just in case verify that you are declaring the grdPaperData variable before the onResult function. The only thing that can make it fail is that it is not finding the column. Make sure you are using the correct case for &quot;score&quot;. Just so that we get all options out of the way, try converting the radio number to a string (radScore.selectedRadio.data.toString()) . You can also use radScore.selectedData instead of radScore.selectedRadio.data.
  60. Thomary

    Thomary

    I want to show a date column in my cfgrid.
    StartDate and EndDate brought in from the query
    show like (Thu Nov 17 00:00:00 GMT - 0500 2005)
    The MySQL column is Format = Date.
    I want to show this in my grid as 11/17/05.

    I've tried to use mask -
    &lt;cfgridcolumn name=&quot;StartDate&quot; header=&quot;Start&quot; width=&quot;250&quot; mask=&quot;mm/dd/yy&quot;&gt;
    but it shows in my grid is mm/dd/yy on all rows.
    Some rows should not have a date at all.

    I tried to set the format in the query but the grid still shows as the (Thu Nov... above)
    Any help would be greatly appreciated.
  61. Thomary

    Thomary

    I'm sorry, setting the format in the query worked. I had the field name twice.

    DATE_FORMAT(queryname.fieldname, '%m-%d-%y') as name,

    Select firstname, lastname, DATE_FORMAT(queryname.startdate, '%m-%d-%y') AS sdate, employeeid, ...
  62. Michael Borbor

    Michael Borbor

    Hi Laura, I just found out about this site It's just outstanding. I applied your example, it worked out, but I got a problem with data bindings, when my page load first I populate the datagrid with a regular query in my CFC, and my bindings work, but after I populate the datagrid with FlashRemoting my bindings stop working why is that? How can I make my bindings work again?

    And another question I got a flash form with an accordion component that has five pages, How can I show a determined page using a button?
  63. Chris
    Can anyone help me? I'm a bit new to ColdFusion, and I can't seem to get this to work correctly.

    Here's my situation...
    I'm getting the following error when trying to update the data displayed in my grid:

    "Error while calling cfc:The parameter FROMDATE to function getGridData is required but was not passed in."

    Here's my code:

    <cfsavecontent variable="getGridData">
       //create connection
       var connection:mx.remoting.Connection = mx.remoting.NetServices.createGatewayConnection("http://cppdc/flashservices/gateway/");
       //declare service
       var myService:mx.remoting.NetServiceProxy;

       var responseHandler = {};

       //put the controls in scope to avoid calling _root
       var pending_results = pending_results;
       var fromdate = fromdate;
       var todate = todate;
       var currcust = currcust;

       responseHandler.onResult = function( results: Object ):Void {
          //when results are back, populate the cfgrid
           pending_results.dataProvider = results;
           if (!results.length){
       alert('No records found');
          }
       }

       //function that receives any error that may have occurred during the call
       responseHandler.onStatus = function( stat: Object ):Void {
        //if there is any error, show an alert
        alert("Error while calling cfc:" + stat.description);
       }

       //get service
       myService = connection.getService("components.getLabData", responseHandler );
       //make call
       myService.getGridData();
    </cfsavecontent>

    My CFC contains the following:

    <cfcomponent name="getLabData" access="public" description="Responds to Flash remoting requests">

       <cffunction name="getGridData" output="false" description="Returns the query for the PENDING RESULTS grid" access="remote" returntype="query">
          <cfargument name="fromdate" required="true"/>
          <cfargument name="todate" required="true"/>
          <cfargument name="currcust" required="true"/>
             <cfquery name="lab_callsp" datasource="#APPLICATION.dataSource#">
             Select a.*, ltrim(rtrim(c.last_name)) + ', ' + ltrim(rtrim(c.first_name)) as phy_name, d.notes
             from mailbox a, customer c, mailbox_features d
             where #session.where_clause# and
             CreateDate between '#fromdate# 00:00' and '#todate# 23:59' and
             <Cfif currcust eq 0><cfelse> a.cust_id = #currcust# and </cfif>
             <!--- <cfif extra_restrict1 eq 1> a.last_name = '#f_lname#' and </cfif>
             <cfif extra_restrict2 eq 1> a.first_name = '#f_fname#' and </cfif>
             <cfif extra_restrict3 eq 1> a.PatientID = '#f_pid#' and </cfif> --->
             a.cust_id = c.cust_id and
             (a.send_notification = 'P' or
             (a.send_notification = 'Y' and
             (select count(msgid) from mailboxmessages b where a.mailbox_id = b.mailbox_id) = 0)) and
             a.mailbox_id *= d.mailbox_id
             order by a.last_name, a.first_name
             </cfquery>
          <cfreturn lab_callsp>
       </cffunction>
    </cfcomponent>

    And finally, the cfform:

    <cfform format="flash" action="components/getLabData.cfc" name="labNav" method="POST" style="horizontalAlign:center; vertical-align:center; border-width:0" skin="halosilver" height="700" onload="formOnLoad()">
       
          <cfformgroup   type="panel"
                      style="font-size:13px; font-weight:bolder; color:##FFF376; headerColors:##2b4b90,##1A46A6"
                      label="-:: LAB RESULTS ::-">
             <cfformgroup   type="tabnavigator"
                         skin="haloBlue"
                         height="650">
                      
                <!--- First page --->
                <cfformgroup   type="page"
                            style="background-color:##FFFFFF;"
                            label="Lab Result Summary">
                   <!--- Show an accordion box for the different sets of results, --->
                   <!--- and use a dataGrid in each to display the data --->
                      <cfformgroup   type="horizontal"
                                  style="color:##000000; font-size:12px; horizontalAlign: center;">
                         <cfinput   type="text"
                                  name="forInput"
                                  width="120"
                                  onchange="#actionFilter#"
                                  label="Filter by:">
                <cfselect   name="column"
                                  label="in:"
                                  onchange="forInput.text=''"
                                  width="120"
                                  style="font-weight:bold">
                   <option value="First_name">First Name</option>
                   <option value="Last_name">Last Name</option>
                            <option value="PatientID">Patient ID</option>
                            <option value="phy_name">Customer</option>
                            <option value="PatientPIN">PID</option>
                            <option value="PatientPhone">Phone Number</option>
                            <option value="CreateDate">Date</option>
                </cfselect>
                         <cfinput   name="fromdate"
                                  value="#fromdate#"
                                  label="From:"
                                  type="datefield"
                                  width="120"
                                  skin="halosilver"
                                  style="color:##000000; font-size:11px; headerColors:##C2D3D6,##FFFFFF">
                         <cfinput   name="todate"
                                  value="#todate#"
                                  label="To:"
                                  type="datefield"
                                  width="120"
                                  skin="halosilver"
                                  style="color:##000000; font-size:11px; headerColors:##C2D3D6,##FFFFFF">
                         <cfinput   name="currcust"
                                  value="#currcust#"
                                  type="text">
                         <cfinput   name="getDataButton"
                                  type="button"
                                  value="Submit Date Filters"
                                  onClick="#getGridData#">
                         
                         <!--- <cfinput   name="#f_name#"
                                  type="hidden">
                         <cfinput   name="#l_name#"
                                  type="hidden">
                         <cfinput   name="#f_pid#"
                                  type="hidden"> --->
                      </cfformgroup>
                   <cfformgroup type="vertical">
                      <cfinclude template="lab_results_summary.cfm">
                   </cfformgroup>
                </cfformgroup>
                
                <cfformgroup   type="page"
                            style="background-color:##FFFFFF;"
                            label="Lab Entry">
                   <cfformgroup   type="horizontal"
                               style="color:##000000; font-size:12px; horizontalAlign: center;">
                      <cfinclude template="lab_entry.cfm">
                   </cfformgroup>
                </cfformgroup>
                
                <cfformgroup   type="page"
                            style="background-color:##FFFFFF;"
                            label="Daily Follow-Up">
                   <cfformgroup   type="horizontal"
                               style="color:##000000; font-size:12px; horizontalAlign: center;">
                      <cfinclude template="daily_follow_up.cfm">
                   </cfformgroup>
                </cfformgroup>
                
                <cfformgroup   type="page"
                            style="background-color:##FFFFFF;"
                            label="Lab Reports">
                   <cfformgroup   type="horizontal"
                               style="color:##000000; font-size:12px; horizontalAlign: center;">
                      <cfinclude template="lab_reports.cfm">
                   </cfformgroup>
                </cfformgroup>
                <cfformgroup   type="page"
                            style="background-color:##FFFFFF;"
                            label="5th Tab">
                   <!--- 5TH TAB'S CONTENT GOES HERE --->
                </cfformgroup>
                <cfformgroup   type="page"
                            style="background-color:##FFFFFF;"
                            label="6th Tab">
                   <!--- 6TH TAB'S CONTENT GOES HERE --->
                </cfformgroup>
                <cfformgroup   type="page"
                            style="background-color:##FFFFFF;"
                            label="7th Tab">
                   <!--- 7TH TAB'S CONTENT GOES HERE --->
                </cfformgroup>
                <cfformgroup   type="page"
                            style="background-color:##FFFFFF;"
                            label="8th Tab">
                   <!--- 8TH TAB'S CONTENT GOES HERE --->
                </cfformgroup>
             </cfformgroup>
          </cfformgroup>
       </cfform>


    Does anyone know why the FROMDATE value isn't being passed to the CFC?
  64. Nevermind... my &quot; myService.getGridData(); &quot; was not returning anything! DUH!
  65. Laura
    Michael,
    Your bindings should work, but it all depends on how you are using them. Regarding the accordion, use myAccordion.selectedIndex = 1; or whatever number you want to show, starting from 0.
  66. Michael Borbor Sanchez

    Michael Borbor Sanchez

    Thank you Laura, I don't know very much about debugging this kind of stuff but definitely something weird happened after I updated my grid, but luckily thanks to yours Real Estate application articles I change my bindings and now everything is perfect. Keep on writing those kind of articles please. I'm sorry to bother you some much but is it possible to embed a select in a grid?
  67. Laura
    Micheal,
    No, it is not possible to have a dropdown in a grid. You can do it with hacks, but I do not recommend them.
  68. Michael Borbor

    Michael Borbor

    Oki doki Laura, thanks for everything.
  69. Ben
    I'm trying to delete specific rows in a grid using checkboxes. I have created a function that is called with an onClick() event with a button but I can't seem to get the value of the rows that are checked.

    I'm trying to pass the values to a cfc, If I use an onchange() event in the <cfgrid> tag I can delete the row but the grid disappears, my preferred method is to use checkboxes but I'm not sure how to get the values selected.

    My grid looks like:
    <cfgrid format="flash" name="blastGrid" rowheaders="false" selectmode="edit" height="400">
    <cfgridcolumn name="CheckBox" type="boolean" header="Delete" />
       <cfgridcolumn name="Email_Sale_id" display="no" />
       <cfgridcolumn name="email_address" header="Email" select="no" />
       <cfgridcolumn name="email_company" header="Company" select="no" />
       <cfgridcolumn name="email_name" header="Contact" select="no" />
       <cfgridcolumn name="email_unsub_date" type="date" mask="MM/DD/YYYY" header="Subscribe Date" select="no" />

    <cfinput type="button" name="removeContact" value="Remove Checked" onclick="showId()"/>
    </cfgrid>

    And the AS function looks like:
    public function showId():Void
    {
    var searchArgs:Object = {};

    searchArgs.id = blastGrid.selectedItem.Email_Sale_id;

    <!--- show clock cursor --->
       mx.managers.CursorManager.setBusyCursor();
       
    blastService.remove(searchArgs);

    }

    Any help would be greatly appreciated.

    Ben
  70. Laura
    Ben,
    This should give you an idea of what to do:
    http://www.asfusion.com/blog/entry/checkboxes-in-a-cfgrid
  71. Tim
    Great work everyone!
    i have a responseHandler function that gets fired when the results return from a call to a cfc.
    my problem is i want to assign certain values from the results to certain fields in the form.
    like so:

    mtHandler.onResult = function(results:Object):Void {
    var mt_array = results;
    PRJ_Name.text = results.getItemAt(0)[&quot;prj_name&quot;];
    PRJ_Desc.text = results.getItemAt(0).prj_desc;
    }

    but no matter what i try, i can seem to get to the actual fields that contain the values i am looking for.

    does anyone know the correct syntax for digging into the result object?

    everything i have tried i have used in Flash and those work.

    thanks
    Tim
  72. Tim
    Update
    i wasnt seeing anything because no records were being returned.
    here is what i used to debug it:
    var mt_array = results;
    var objString = &quot;&quot;;
    for(var i in mt_array){
    objString += i + &quot; = &quot; + mt_array[i] + &quot;\n&quot;;
    }
    alert(objString);

    this will show all the object inside of the result object.
    the syntax that worked for me was:
    formfield.text = results.getItemAt(0).item

    but if you have more than 1 recordset being returned you will have to loop over each row to get the values out.

    Regards
    Tim
  73. John DeGrood

    John DeGrood

    I see there are already tons of comments to this topic; however, I did not see any relating to multiple grids in a form. For example, (In honor of the great Ben Forta) if I have a movie database and I run a query to get all of the movies from the database, I can use the onResult to place everything into my &quot;moviesGrid&quot;, but what I need to do now is have the onChange event identify when a movie is selected in the &quot;movieGrid&quot; and query the database to select all of the actors associated with the selected movie and then populate the &quot;actorsGrid&quot;.
  74. Pegarm
    No matter what I do, I'm receiving an &quot;Event Handler Exception&quot; error when I'm trying to populate a CFGRID using Flash Remoting. Any thoughts as to what would be causing this ever so descriptive error?
  75. GrassHopper

    GrassHopper

    Yet another Newbie question...

    I have grid with checkboxes and use flash remoting to populate and update the grid based on this exaample.
    I can selectively delete rows ( thanx to http://www.asfusion.com/blog/entry/checkboxes-in-a-cfgrid)
    I have set selectmode to 'edit' but am at a loss as to how I can identify new and updated rows and update the database using flash remoting.

    Ideas/examples anyone?


  76. GrassHopper

    GrassHopper

    Yet another Newbie question...

    I have grid with checkboxes and use flash remoting to populate and update the grid based on this exaample.
    I can selectively delete rows ( thanx to http://www.asfusion.com/blog/entry/checkboxes-in-a-cfgrid)
    I have set selectmode to 'edit' but am at a loss as to how I can identify new and updated rows and update the database using flash remoting.

    Ideas/examples anyone?


  77. Jimmy
    What am I doing wrong. I download the example and when I ran the It works. So then I tried to edit the cfc and changed a few names like adam to test1. Then when I recopy the files back to the server I get a the same result as the orginal example. Why is my new data not displaying.

    Also I tried doing my custom query on a different folder, and when I click the populate button I get still get a blank grid, but for some reason I see a scroll bar poping up inside the grid.

    Can anyone please help me.
  78. Sandra
    Hi,

    Is there any way to populate the grid using flash remoting w/o using the search function, or w/o having the user to press a button to populate the grid?

    I just want the users to select an item in the grid and then populate the forms so that they can edit, add and delete records from the DB.

    Thanks.
  79. George
    I can not figure out how to populate the grid onLoad either. Can anyone help?
  80. Laura
    Sandra, George,
    this post should help you:
    http://www.asfusion.com/blog/entry/knowing-when-the-cfform-data-arrives
  81. Paul
    I have read your articles and used several examples in setting up my remoting environment. I am having a problem displaying results in a cfgrid. There are no errors in the remoting and the results.length is always the same. But 1 out of 10 times the grid displays no data. When I use mygrid.getItemAt(1)['Labor_Code'] it will return the expected data, but nothing is displayed in the grid. Can you help?
  82. Neil
    case sensitivity issue, I almost guarantee it. I had the HARDEST damn time getting around that in the beginning.
  83. Paul
    Neil

    I have verified the DB columns names and Grid column names are identical. I would expect a case sensitive problem to fail all the time. I have noticed that sometimes the data flashes in the grid and then disappears. It only fails when the data is loaded using remoting in the onLoad event. If I load the grid from a query on the page it works every time.
  84. Laura
    Paul,
    If that is your problem, then check this post:
    http://www.asfusion.com/blog/entry/knowing-when-the-cfform-data-arrives
  85. eatmorepossum

    eatmorepossum

    This site and flash forms are very cool.

    Instead of returning a query to a cfgrid I am trying to return an array. Using one of the tips above i am outputting records in an alert.

    But as of yet, I have been unsuccesful getting the data in the cfgrid named attendeesGrid

    Here is what my return looks like so far (outputting records in the alert but not the grid)

          AttendeeResponseHandler.onResult = function( results: Object ):Void {

             
             if (!results.length){ alert('No records found'); }
             else {
             var arrattendees = results;
                var objString = "";
                      
                for(var i in arrattendees){
                attendeeGrid.dataProvider.addItem(results.getItemAt(i));
                objString += i + " = " + arrattendees[i] + "\n";
                }
                alert(objString);
                
             }
             attendeeGrid.selectedIndex = undefined;
             mx.managers.CursorManager.removeBusyCursor();
          }      

    I have a feeling this is an easy one but I am fairly new to AS.
  86. eatmorepossum

    eatmorepossum

    appologies for the tripple post.

    I could not figure out the syntax to read the contents of an array into a flash forms cfgrid. So I gave up and utilized a querynew() query to gather my data instead of an array.

    Worked fine for now but i would like to know how to use an array as well.

    I also am curious to know what the difference in overhead is between the array and a querynew().

    thanks,
    Chris
  87. Riz
    Great example, I got it running, however after remoting, the values displayed in the cfgrid don't seem to be defined! This is only a problem after the values have changed and not if running a query prior to remoting.

    I am using this command on the cfgrid to link to another page without any success!

    <cfgrid name="contactList" query="memberList" height="200" rowheaders="false"
       onchange="getURL('#script_name#?name='+contactList.dataProvider[contactList.selectedIndex]['name']);">

    The value for name (which is selected in the cfgrid) in the URL shows as "undefined". And yes I have tried changing the key to all uppercase without any success!

    Any insight would be most appreciated as this is quite frustrating.
  88. Riz
    Problem solved!

    To all those with a similar issue I changed :

    contactList.dataProvider[contactList.selectedIndex]['name'])

    to

    availList.selectedItem.name
  89. Bradford

    Bradford

    I notice the databinding works for cfformitem with this example but not cfinput. Any ideas why?
  90. tj
    Thanks for the examples, this has helped me a lot in my first real foray into Flash Forms.

    So i am kind of stuck here. I am using a grid to edit and add categories and rather than requery each time I do an insert or update statement I am just trying to set the IDs of the new categories using the return value from my query. it works fine if I add one record at a time, but if I try to do multiples it only edits the value of the last row in the grid.

    example (chopped out a lot of code for readability):

    responseHandler.onResult = function( results ):Void {
          //when results are back, do something here
          categories.editField(categories.selectedIndex,"CategoryID",results.items[0].NewCategoryID);
       }


    //loop through grid

       for (var i = 0; i < categories.length; i++) {

          categories.selectedIndex=i;   
          
          
        if(categories.getItemAt(i)['CategoryID'].length == 1) {
          
             
       myService.insertNewCategory(categories.getItemAt(i)['CategoryName'],categories.getItemAt(i)['Disabled'],categories.getItemAt(i)['CategoryIsPending']);

        }
             
       
       
       }
  91. Joseph Abenhaim

    Joseph Abenhaim

    Hi,

    First of all great site!

    I'm having this problem where i got a grid that gets populated onLoad, however, i'm having issues where it's only populating sometimes and the data stays there and the other times I see the data loaded then it disappears. I'm not sure what causes this but it's really annoying and i havent found a way to fix it. Any help would be greatly appreciated.

    Thank you!.
  92. Laura
    tj,
    I am sure the records get edited, but when you return the id back, you are only showing the change on the selected item when you use categories.selectedIndex

    You would have to use a similar function to the one we used in the Real Estate tutorial (http://www.adobe.com/devnet/coldfusion/articles/flashforms_pt2_06.html)
    Look for findItem in that page. You will need to find the item you edited in the grid. That will guarantee that you edit all items that were edited, not only the currently selected one.

    Joseph,
    You need to read this post:
    http://www.asfusion.com/blog/entry/knowing-when-the-cfform-data-arrives
  93. AHE
    I am populating my cfgrid from a query via flash remoting. The cfgrid is editable. I am trying to get the user to check/uncheck a checkbox that is returned from the query resultset. Once the user is done with the selections, I am asking the user to click the submit button to post the form to another cfm template to send the selection to my cfc to be sent to the database to run the update query.
    I have a problem and a question:
    - When submitting the form to the .cfm I am dumping the form and none of the cfgrid changes are showing.
    - When I create a query object (using queryNew()) in CF and use it instead of the resultset returned by the flash remoting and dump the form I see the changes I made in the form struct.
    - I saw a couple of entries in the blog saying to use results._items (which did not work for me) or to loop through the results and do the following

    for (var i = 0; i < results.length; i++){
    myGrid.dataProvider.addItem(results.getItemAt(i));
    }
    The above was causing only one item to show in my form dump (arrayLen was showing as 1 and the array was having 2 structs). Is this due to the index start at 0 in AS while it starts at 1 in CF. How would I fix this problem?
    - Am I going the wrong route by trying to submit to a .cfm. I am new to Flash/Remoting. I am trying to use CF because this is what I know but it may be the wrong way.
    Your help is greatly appreciated.
  94. AHE
    I am unable to retain the cfgrid information after updating and submitting the grid. This is occurring only when the data is coming from a flash remoting call to a cfc. somehow the query resultset coming from flash remoting is not indexed. When I dump the form in the page I submit to, it onl has empty arrays. If I create a query in the cfm page by queryNew() that is working fine (has an index). Did anyone run into this or found a solution or a work around for it???
    Thanks in advance.
    Ahmed.
  95. Laura
    Ahmed,
    We will appreciate if you don't repost the same question all over the place, I will delete all others. Thanks.
    Read my response #42 ( http://www.asfusion.com/blog/entry/populating-a-cfgrid-with-flash-remoting#comment-1455 )
    It doesn't really make a lot of sense mixing remoting with normal submit, particularly if you don't know what's going on under the covers (how flash forms update the hidden fields of the html form)
    Also, you can only get on the post page what's been changed, not all of the records in the grid (regardless of how you populate the grid)
  96. AHE
    Sorry for the multiple posts.
    I tried your post on 42 but it did not work. Here is my code snippet and what I am trying to do.
    <cfform name="frmPSettings" action="index.cfm?event=pSettings" format="flash" skin="haloblue" method="post" height="400" width="700" onload="formOnLoad()">
    <cfif agentObj.isMaster()>
    <cfselect name="selectAgency" label="Agency Code" query="variables.qrySubAgents" display="agentCode" queryPosition="below" onChange="getPSelection(); ">      <option selected="selected" value="defaultValue">Select Agent</option>
    </cfselect>
    </cfif>
    <cfgrid rowheaders="no" name="pPersonalA" selectmode="edit" height="250" width="330" colheaderbold="yes" query="variables.pSupWebServiceSelection">

    <cfgridcolumn display="yes" name="FLAG" header="" width="80" type="boolean"/>
    <cfgridcolumn display="no" name="BRANCH"/>
    <cfgridcolumn display="no" name="CATEGORY"/>   
    <cfgridcolumn display="yes" name="CATEGORYDESC" select="no" header="Personal Auto" width="170" >
    </cfgrid>
    </cfform>
    The actual change to the combobox triggers the getPSelection() method and that makes the Flash Remoting connection to my cfc that raturns the query resultset which is bound to my cfgrid pPersonalA. The grid populates fine but if show rowheaders it shows no index for the records. When I make a change to the records and submit and dump the form I see empty arrays for all the grid variable.
    I also tried the method you mentioned in 42 but I got the same result. Am I missing something?
    Thanks again for you help.
  97. AHE
    I have checked with Adobe Support and this turned out to be a known issue that is being addressed in their ColdFusion MX 7.02 (it is currently in Beta). This is according to Adobe CFMX 7 support. So the issue is:
    When a CFGRID (that is populated on an event by Flash Remoting) with selectmode="true" get edited and submited the action page does not know what exactly was edited.
    If the CFGRID is populated by CF (not Flash Remoting) then everything works fine because the CFGRID is populated by an array of structures (not a Flash Remoting recordset object - which does not have an index).
  98. Kelly
    I am working through a modified example where I am calling a cfc that requires 3 arguments. I am using 3 hidden fields in my form to pull that data. When I click on the button to make the call, it appears to make the call and my grid appears to be populated (i.e., should have 2 records and the grid looks like there is two records - but no data is shown and no error msgs appear). I have checked the column names to make sure they match.

    See code below - actionscript:
    <cfsavecontent variable="essActionOpen">
    var connection:mx.remoting.Connection = mx.remoting.NetServices.createGatewayConnection("http://localhost:8500/flashservices/gateway/");

    var myService:mx.remoting.NetServiceProxy;

    var responseHandler = {};

    var essentialsGrid:mx.controls.DataGrid = essentialsGrid;

    responseHandler.onResult = function( results: Object ):Void {
    essentialsGrid.dataProvider = results;
    }

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

    myService = connection.getService("dakota.components.remoteQueries", responseHandler );

    myService.getEssentialData({evaltask_evalrole_code:_root.evaltask_evalrole_code.text,jd_uuid:_root.jd_uuid.text,eval_uuid:_root.eval_uuid.text});      
    dynamicPanel.selectedIndex = 1;
    </cfsavecontent>

    CFGRID
    <cfgrid name="essentialsGrid" rowheaders="false" height="95" width="910">                     
    <cfgridcolumn width="65" name="ess_sequence" header="Seq" />
    <cfgridcolumn name="ess_text" header="Essential" />
    <cfgridcolumn width="100" name="mgrScore" header="Mgr Score" />
    <cfgridcolumn width="100" name="mgrWeight" header="Weight" />
    <cfgridcolumn width="100" name="selfScore" header="Self Score" />
    <cfgridcolumn width="100" name="peerScore" header="Peer Score" />   
    <cfgridcolumn name="ess_uuid" display="no"/>
    <cfgridcolumn name="userEvalEss_uuid" display="no"/>      
    </cfgrid>
  99. Laura
    Kelly,
    I know that you said you checked the column names... However, if the grid gets populated but the columns are empty, it is because Flash can't find what to show there. I would double check the columns (they need to match your query/db column). I would do the query and manually alias the columns so that I am sure what case I am using. (ie: SELECT columnA as columnA)
  100. Daryl
    I'm quite new to Coldfusion, Flash, Remoting.. all of it.

    I've used Flash Remoting very slightly in Flash and now need to use it in CF.

    I was able to get this example to work fine with the manually generated query posted here but I'm using stored procedures and have been unable to make it work.

    <cffunction name="getUsers" access="remote" returntype="query">
          <cfstoredproc procedure="TE_PAGE_EDIT.getAllUsers" datasource="#APPLICATION.TEPORTALDB#">
             <cfprocresult name="qGetAllUsers">
          </cfstoredproc>
       </cffunction>


    It returns the error "Returned Value is not of type: Query"

    I tried just hitting the database directly via a cfquery but was unable to populate the cfgrid in that manner either.

    I'm sorry if I'm just doing something stupid, but any help would be appreciated.
  101. Laura
    Daryl,
    You are not returning the query you make with your stored procedure so the function is returning void (which is why the returned value is not a query).
    You should do something like <cfreturn qGetAllUsers /> at the end of your function.
  102. Daryl
    That worked.

    Thank you very much. It's always something simple that eludes me :)
  103. Robert
    I was able to get everything working with the remoting except for one thing. It's not a part of this tutorial but is related.

    I would like to have a control on one form to populate a grid on a seperate form using Flash Remoting. When I put the button in the same form it works fine but when it's moved to another form, the grid doesn't populate. I assume I need to point to identify the form and control name in the Actionscript instead of hust the control name.

    What method is used to direct the data to another form?
  104. Laura
    Robert,
    By another form you mean a different <cfform> block? If so, then the answer is that it is not possible with remoting. You can only communicate between different flash movies by using local connection, which is not an easy topic.
  105. Robert

    Robert

    I gave up on it. I was attempting to allign the form in a specific manner on the page using divs. I was forced to use a different <cfform> in each div. I then tried to align things with a table but it didn't like that either. I'm now doing my best with cfformgroups but it doesn't look nearly as good as I was hoping for.
  106. Tony Eckert

    Tony Eckert

    Is there any way to combine "populating a cfgrid" with "filtering a cfgrid while typing" ? For a long time, I've used a cfgrid with the filter and column selection box. This has worked fine, but I notice that the app takes a bit longer to load when the cfgrid is being populated with a database of 2000+ entries. So I thought I would try this populate method, and the application loaded twice as fast. I was able to successfully populate my grid using a submit-style button.

    The problem came when trying to combine the two techniques. I could populate the grid with the button, but the grid would wipe when I began typing in the filter box. Is there a way that I could get both of these to cooperate together?
  107. Laura
    Tony,
    Your question is such a frequently asked one that I added a note in the post.
  108. Tony Eckert

    Tony Eckert

    Ah you've saved me again Laura. Thanks!
  109. Kelly
    I am having trouble getting my remoting to work on a new page I have created. I have remoting and the grid feature working on a different page, so I copied the code changes a few variable names, but the remoting calls are not being made. I am able to get alert boxes to popup inside the function but my actual remoting call to a cfc doesn't appear to be firing. I have downloaded ServiceCapture and can see the remoting calls being fired on the other page, but not this one. I am also not getting any error messages.

    Any suggestions!!!

    Kelly

    Here is my code in the cfformitem script tag...
    <cfformitem type="script">
    public function formOnLoad():Void {   
       manageGoals.myGlobalObjects = {};      
       setUpGoalRemoting();
    }

    public function setUpGoalRemoting():Void {
       var connection:mx.remoting.Connection = mx.remoting.NetServices.createGatewayConnection("http://#cgi.HTTP_HOST#/flashservices/gateway/");      
       
       var componentPath:String = "#request.componentPath#.services.evalGoalService";
          
       var goalService:mx.remoting.NetServiceProxy;
       var responseHandler:Object = {};      
       
       // put controls in function scope    
       var goalGrid = goalGrid;
       
       // handle personal goals by default onResult function
       responseHandler.onResult = function( results: Object ):Void {         
             alert(results);
             //goalGrid.dataProvider = results;   
       }            
       //default error handler
       responseHandler.onStatus = function( stat: Object ):Void {
          //if there is any error, show an alert
          alert("Error: " + stat.description);                  
       }         
       
       // store service in global variable
       manageGoals.myGlobalObjects.goalService = connection.getService(componentPath, responseHandler );
    }
    //gets personal goals for specific employee
    public function getPersonalGoals() {
       //alert("asg_uuid: " + eeSelectList.selectedItem.data );
       //alert("goalCurrent: " + goalCurrent.selectedData );
       manageGoals.myGlobalObjects.goalService.getPersonalGoals({asg_uuid:eeSelectList.selectedItem.data,goalCurrent:goalCurrent.selectedData});

    </cfformitem>
       
    }
  110. Laura
    Kelly,
    Are you calling formOnLoad() in the onload attribute of cfform?
  111. Kelly
    Yes I am. I have even put an alert in there to make sure the onload function was working. I just can't figure out why the remoting calls aren't working.
  112. Laura
    Kelly,
    Did you try hardcoding the variables in # signs manually? (I don't see any <cfoutput> tag around them)
  113. Kelly
    duh! one step i completely forgot to do when creating my page, i wish the cf compiler would have picked that one up!
  114. nel
    HI ,
    I am new to coding and tha help I needed is I have datagrid as a question format that is one of the colums need to have the question which will be the text and the rest of the columns will be the answers like yes no and so there are so may like that I need to use datagrid any help that will be great
  115. Jason
    How do I deal with null values returned from my cfc? I've been doing this:

    if (mytext.text = 'null'){
    mytext.text = '';
    }

    This code only works if done in the response handler function. The problem I'm having is that I have about 40 fields to return, and I seem to be hitting a size limit for the response handler. I suppose I could split this into two remoting calls, but would prefer not to.

    Is there a cleaner way of doing this? I'm using MySQL.
  116. Laura
    Jason,
    I am not sure why you have a problem with nulls. Usually, null values are returned as empty strings, not the string "null". You can also use conditional bindings, but it all depends on what you are trying to accomplish.
  117. Jason
    Laura,

    I believe that it had to do with MySQL. It would actually return the word "Null". What I ended up doing to resolve this was change my select statement in the cfc to something like this:

    SELECT    
    IFNULL(myText,'') As myText,
    IFNULL(myText2,'') As myText2,
    FROM Test_Table
  118. Laura
    Jason,
    As I said, I don't think you need to do anything if the column is null. You should receive the column value as an empty string anyway. But... mySql drivers always have strange behaviour, so I guess you should check if that is the case.
  119. Justin
    I am still having a problem with the related grids that I am using. Here's the issue:

    I have a page with flash form grids. The four grids are related (eg GreatGrandParent-GrandParent-Parent-Child). I have two clients, both of whom login to the same site. However, when client A logs in, the system uses Database A. And when client B logs in the system users Database B. Client A's data filters properly all the way down to the child level. However, client B's does not. Client B's data filters properly in the GreatGrandParent and GrandParent levels, but when it gets to the Parent and Child, rows are included that do not belong in this family hierarchy. The only thing I can think of as to the cause of the problem is the database, so I looked through the data quite well and found no differences in the format of the data. Client B's database is a copy of Client A's, so perhaps something in the structure didn't crossover?

    Does anyone have any suggestions/ideas of where to look or what the problem could be?

    Thanks,
    Justin
  120. Carl
    Can someone tell me why you can not refer to grid using the grid.dataProvider[grid.selectedIndex]["columnname"] syntax after the grid has been refreshed using remotely? Here is a simple example (files would need to be located at [webroot]/FlashFormTest):
    Form cfm file:
    <cfset objTest = CreateObject('Component','myComponent') />
    <cfset rs = objTest.myFunction() />

    <cfform name="myForm" format="flash" width="300" height="300">
       <cfformitem type="script">
          function callService()
          {
             var connection:mx.remoting.Connection = mx.remoting.NetServices.createGatewayConnection(
                 "http://localhost/flashservices/gateway/");
             var myService:mx.remoting.NetServiceProxy;
             var responseHandler = {};
             responseHandler.onResult = function( results: Object ):Void
             {
                 _root.myGrid.dataProvider = results;
             }
             
             responseHandler.onStatus = function( stat: Object ):Void
             {
                 alert("Error while calling cfc:" + stat.description);
             }
             
             myService = connection.getService("FlashFormTest.myComponent", responseHandler );
             myService.myFunction();
          }
          
          function getNameFromGrid()
          {
             _root.nameFromGrid.text = myGrid.dataProvider[myGrid.selectedIndex]["name"];
          }
       </cfformitem>
       <cfgrid name="myGrid" query="rs" height="100" rowheaders="no" onchange="getNameFromGrid()">
          <cfgridcolumn name="id" header="ID" />
          <cfgridcolumn name="name" header="Name" />
       </cfgrid>
       <cfinput type="button" name="btnCallService" value="Refresh Grid" onClick="callService()" />
       <cfinput type="text" name="nameFromGrid" value="" />
    </cfform>


    Component cfc file:
    <cfcomponent>
       <cffunction name="myFunction" access="remote" returntype="query">
          <cfscript>
          myQuery = QueryNew("id,name","Integer, VarChar");
          QueryAddRow(myQuery, 2);
          QuerySetCell(myQuery, "id", 1, 1);
          QuerySetCell(myQuery, "name", "test 1", 1);
          QuerySetCell(myQuery, "id", 2, 2);
          QuerySetCell(myQuery, "name", "test 2", 2);
          </cfscript>
          <cfreturn myQuery>
       </cffunction>
    </cfcomponent>
  121. Carl
    I am answering my own questions here but thought it might be helpful if anyone ran into this problem. Apparently the results object is slightly different when returned using remoting. The only change I needed to make was:
    change
    _root.myGrid.dataProvider = results;
    to
    _root.myGrid.dataProvider = results._items;


    I happen to see the results._items syntax on another site. I never could find any Adobe documentation to that effect.
  122. Laura
    Carl,
    Interestingly, this post had a note about that after the first code segment ;)
  123. Rodrigo
    I've been using remoting with great success during the last 6 months, but a custommer came to me asking to create a cfgrid that let u grab 10 records each time so he can "navigate" the results of a search (The grid is filled using remoting), i have some ideas on how to do this, but at this time my brain has totally fried... :) ne help, link, suggestion, example, tutorial or ne thing that can point me?
  124. AuroraCF

    AuroraCF

    I received an error "Error While calling cfc:Service my_cfm not found." What am I missing here? Flashservices/Gateway not configured or installed?

    Help please!!

    Thanks,
    Pn
  125. Mark Cadle
    Chances are your cfc is not in the root level folder. Check the line:

    myService = connection.getService("COMPONENT_NAME_HERE", responseHandler );
    myService.myFunction();
    }

    Remember to use dot notation for path specification too!
  126. AuroraCF

    AuroraCF

    Mark,

    Thanks for your feed back, after research/reading I realize that Flas remoting server start from root. All I have to do is to tell it to look in the sub-folder, that solved the problem.

    Thanks again, this is GREAT forum.

    Pn
  127. rudy750

    rudy750

    I tested flash remoting in one page got it working great. Now I need to use it accross several pages.

    Tried writing a .as file with the connection function and then just including it in the pages that need remoting. Cant get that running... help.
  128. Brad
    Hi I am able to populate a cfgrid via a regular query but then am populating a dropdown insdie the grid. I am having a hard time going about trying to detmine how to code the insert/update/delete portions of the grid. I would appreciate any suggestions or direct me where I could find better info. Thanks for this site!! Here is my code:

    <cfformitem type="script">
          function getSelectData(){
          //create connection
          <CFOUTPUT>
             var connection:mx.remoting.Connection = mx.remoting.NetServices.createGatewayConnection("http://#cgi.HTTP_HOST#/flashservices/gateway");
          </CFOUTPUT>      
          //declare service
             var myService:mx.remoting.NetServiceProxy;
             var responseHandler = {};
             var COMBOBOX_DATA_PROVIDER = COMBOBOX_DATA_PROVIDER;
             responseHandler.onResult = function( results: Object ):Void
             {
          //when results are back, populate the COMBOBOX_DATA_PROVIDER then set the cellRenderer
                _global.COMBOBOX_DATA_PROVIDER = results;
             _root.interactionsGrid.getColumnAt(2).cellRenderer = ComboBoxCellNew;
             }
             
             responseHandler.onStatus = function( stat: Object ):Void
             {
          //if there is any error, show an alert
             alert("Error while calling cfc:" + stat.description);
             }
          //get service
          myService = connection.getService("CDMS.cfc.contact", responseHandler );
          //make call
          myService.getContactTypes();
    }
       </cfformitem>

       
       <cfgrid name="interactionsGrid" width="725" selectmode="EDIT" rowheight="25" rowheaders="No" align="TOP" height="200" query="getInteractionsInfo" delete="Yes" insert="Yes">
          <cfgridcolumn name="CONTACT_DATE" header="Contact Date" width="100">
          <cfgridcolumn name="CONTACT_TYPE" header="Contact Type" width="150">
          <cfgridcolumn name="NOTES" header="Notes" width = "475"/>   
       </cfgrid>
  129. rudy750

    rudy750

    your action page will have The FORM struct in your action page will contain 3 rows per column in the grid (interactionsGrid):

    interactionsGrid.RowStatus.Action
    interactionsGrid.NOTES
    interactionsGrid.Original.NOTES


    using your column named NOTES the array contains the actions that the user performed on the grid. For example:

    interactionsGrid.RowStatus.Action
    1. I
    2. D
    3. U

    interactionsGrid.NOTES
    1. a note to be inserted
    2.[empty string]
    3. a note to be changed

    interactionsGrid.Original.NOTES
    1 [empty string]
    2 a note that will be deleted
    3 a note that needs changing

    So that tell you that at position 1 an Insert action was performed etc...
    if you follow the arrays,

    the first one tells you the action
    the 2nd tells you the new value.
    the 3rd tells you the original value on the table.

    You can loop thru these arrays to perform your SQL statements using the key in the array to keep yourself in
    track.

    I hope this answers your question, let me know if you need more clarification:
  130. Brad
    Hi I am able to populate a cfgrid via a regular query but then am populating a dropdown insdie the grid. I am having a hard time going about trying to detmine how to code the insert/update/delete portions of the grid. I would appreciate any suggestions or direct me where I could find better info. Thanks for this site!! Here is my code:

    <cfformitem type="script">
          function getSelectData(){
          //create connection
          <CFOUTPUT>
             var connection:mx.remoting.Connection = mx.remoting.NetServices.createGatewayConnection("http://#cgi.HTTP_HOST#/flashservices/gateway");
          </CFOUTPUT>      
          //declare service
             var myService:mx.remoting.NetServiceProxy;
             var responseHandler = {};
             var COMBOBOX_DATA_PROVIDER = COMBOBOX_DATA_PROVIDER;
             responseHandler.onResult = function( results: Object ):Void
             {
          //when results are back, populate the COMBOBOX_DATA_PROVIDER then set the cellRenderer
                _global.COMBOBOX_DATA_PROVIDER = results;
             _root.interactionsGrid.getColumnAt(2).cellRenderer = ComboBoxCellNew;
             }
             
             responseHandler.onStatus = function( stat: Object ):Void
             {
          //if there is any error, show an alert
             alert("Error while calling cfc:" + stat.description);
             }
          //get service
          myService = connection.getService("CDMS.cfc.contact", responseHandler );
          //make call
          myService.getContactTypes();
    }
       </cfformitem>

       
       <cfgrid name="interactionsGrid" width="725" selectmode="EDIT" rowheight="25" rowheaders="No" align="TOP" height="200" query="getInteractionsInfo" delete="Yes" insert="Yes">
          <cfgridcolumn name="CONTACT_DATE" header="Contact Date" width="100">
          <cfgridcolumn name="CONTACT_TYPE" header="Contact Type" width="150">
          <cfgridcolumn name="NOTES" header="Notes" width = "475"/>   
       </cfgrid>
  131. Brad
    rudy750,

    You are a life saver. That helped tremediously! What you said makes sense and it pointed me to some other examples as well. I am hoping I can take a couple days and figure it out. I am a little worried with putting the dropdown inside the grid and how that will interact. I am sure I will check back if I have questions.

    Thanks again!
  132. rudy750

    rudy750

    I dont know that you can put a cfselect as a column in a cfgrid? I did some research on that and I couldn't find a way.

    If you figure something out let me know! If you get stuck let me know
  133. Brad
    rudy,

    Try this link:

    http://cfsilence.com/blog/client/index.cfm/2006/6/30/CFGRID-ComboBox-Cell-Renderer--Dynamic-Query

    This is what I used to figure my code out. It uses ActionScript which I didn't have experience with before so it took me a while to figure it out. Good Luck.
  134. William Green

    William Green

    I am using the following code to handle an update response using flash remoting:

    <code>
    responseHandler.update_Result = function( results: Object ):Void {               
                   var item:Object = results.item;
                   var index:Number = results.index;
                                  
                   //replace updated email listing                  
                   propGrid.replaceItemAt(index,item);
                   
                   //remove busy cursor
                   mx.managers.CursorManager.removeBusyCursor();
                   //show a message
                   alert(results.message);                     
                   }
    <code>

    However, the grid row is empty after the update. I have tested to make sure that the results object is actually returning values. That part is working fine. The same thing happens with addItemAt function.

    I have used this exact code on another form and it works fine. What am I doing wrong?
  135. shelts

    shelts

    is there a maximum amount of name-value pairs that you can do in a remote call to a cfc when doing flash remoting? I'm doing flash remote call to a cfc and I can only do a total of 8 value. when I go to 9 name-value pairs, the form doesnt render
  136. Brad
    Anyone ever have issues with certain controls not rendering when s Datagrid is loaded with ComboBoxes inside of it? I am getting very strange behavior with using multiple combo boxes and them not rendering all the time when the page/flash form loads.
  137. kll57
    Hi,
    Hoping someone can help with a stored procedure / Coldfusion MX / Flash form with remoting: My application is based on the Real Estate application using services and DAO's. For basic queries everything is working fine. I'm now trying to put in more functionality and need to use Stored Procedures for all of the database interaction, so I thought I'd move everything into the stored procedure.

    My remoting is set up and working.

    The following code snippets are just dealing with a simple query that I'm trying to call from a Stored procedure. When the query is in the DAO it works to populate the grid. The following code is what works. The change that I made is in the camsUserDAO.cfc that now calls a stored procedure.

    This is the function call to the service from the Coldfusion Flash Form.

    index.cfm:

    public function getUserid(userno:String):Void
    {
    var userArgs:Object = {};
    <cfoutput>
    userArgs.userno = userno;
    </cfoutput>
    _global.listingService.queryUserid(userArgs);
    mx.managers.CursorManager.removeBusyCursor();
    }

    This is the response handler:

    responseHandler.queryUserid_Result = function (results: Object ):Void
    {
    userIdGrid.dataProvider = results.items;
    mx.managers.CursorManager.removeBusyCursor();
    }


    This is the Listing Service: userListingService.cfc

    <cfcomponent displayname="userListingService" access="remote" hint="Remote Facade for camsUserDao">

    <cffunction name="queryUserid" access="remote" returntype="query" output="false" hint="Returns a query of all userids for the selected user">
    <cfargument name="userno" required="true" type"string" hint= Primary Key -userno of selected user">
    <!--- Call a component sitting in memory ( applicaiton scope) --->
    <cfreturn application.userListingManager.queryUserid(argumentCollection=arguments) />
    </cffunction>

    </cfcomponent>

    This is the DAO: camsUserDAO.cfc - This is a simplified version of the query, not all columns were included.

    <cfcomponent displayname="userListingManager" hint="Add, update, delete users">

    <cffunction name="queryUserid" access="public" returntype="query" output="false" hint="Returns userids for a selected user">
    <cfargument name="userno" required = true type="string" hint= Primary Key -usernoof selected user">
    <cfquery name="useridQuery" datasource="#dsn#">
    select user_id
    ,user_no
    from user_accts
    where user_no = <cfqueryparam value="#Trim(userno)#" cfsqltype="cf_sql_varchar" />
    </cfquery>
    <cfreturn useridQuery />
    </cffunction>

    </cfcomponent>

    Change to call Stored procedure: It is an Oracle package with several stored procedures in it. The package has been compiled and the procedure works when tested in Toad. I am using a ref Cursor to pass back the query record set.

    <cfcomponent displayname="userListingManager" hint="Add, update, delete users">

    <cffunction name="queryUserid" access="public" returntype="query" output="false" hint="Returns userids for a selected user">
    <cfargument name="userno" required = true type="string" hint= Primary Key -usernoof selected user">
    <cfstoredproc procedure="userid_pkg.getUserids" datasource="#dsn#">
    <cfprocresult name"qUserids">
    <cfreturn useridQuery />
    </cffunction>

    </cfcomponent>


    The call in the form is getting the correct user_no to pass into the DAO procedure call, but nothing is returned to the datagrid when using the stored procedure.

    Do I need to put the storedprocedure information in the userListingService.cfc function or call the <cfstoredproc> somehow? I've been searching for help for 2 days and am at lose, I hope someone can help me to resolve this.

    Thanks in advance for any help.
    Kim
  138. Clayton

    Clayton

    I am trying to use the "Filtering as you type" example from ASFUSION. I modified the code for my application.

    I use a large recordset and the queries take awhile to execute; To help the search along I am saving it to an array.

    I want to use the array for the cfgrid data instead of requerying the database.

    When I run the code I get the error:
    Attribute validation error for tag CFGrid.
    The value of the attribute Query, which is currently memberList, is invalid.

    Here is my Code:
    <!--- Set Count Vars --->
    <cfset qCount = query_HList.recordcount>

    <!--- Declare the array --->
    <cfset memberList=arraynew(2)>

    <!--- Populate the array row by row --->
    <cfloop query="query_HList">
    <cfset memberList[CurrentRow][1]=facility_id>
    <cfset memberList[CurrentRow][2]=name>
    <cfset memberList[CurrentRow][3]=address>
    <cfset memberList[CurrentRow][4]=city>
    <cfset memberList[CurrentRow][5]=state>
    </cfloop>

    <cfsavecontent variable="actionFilter">
       if(_global.arrMembers == undefined) _global.arrMembers = data.dataProvider.slice(0);
       var arrMembers = _global.arrMembers;
       var arrDisplay:Array = [];
       var fortext = forInput.text.toLowerCase();
       var selected = column.selectedItem.data;
       
       for(var i = 0; i < arrMembers.length; i++)
        {
          if(arrMembers[i][selected].toString().substr(0,fortext.length).toLowerCase() == fortext)
          {
             arrDisplay.push(arrMembers[i]);
          }
       }
       
       data.dataProvider = arrDisplay;
    </cfsavecontent>

    <!--- Start Search Panel --->
    <cfform name="myForm" format="flash" width="800" height="500">
       <cfformgroup type="panel" label="Select Hospital">
          <cfformgroup type="horizontal">
             <cfinput type="text" name="forInput" width="120" onchange="#actionFilter#" label="Filter by:">
                <cfselect name="column" label="in:" onchange="forInput.text=''" width="90">
                   <option value="facility_id">Facility ID</option>
                   <option value="name">Hospital Name</option>               
                   <option value="address">Address</option>
                   <option value="city">City</option>
                   <option value="state">State</option>
                </cfselect>
          </cfformgroup>
          
    <!--- Start Grid --->
             <cfgrid name="data" height="200" rowheaders="false" query="memberList">
                <cfgridcolumn name="facility_id" header="Facility ID" width="100">
                <cfgridcolumn name="name" header="Hospital Name" width="225">
                <cfgridcolumn name="address" header="Address" width="275">
                <cfgridcolumn name="city" header="City" width="100">
                <cfgridcolumn name="state" header="State" width="25">
             </cfgrid>
       
       </cfformgroup>
    </cfform>

    <cfform format="flash" preloader="true" width="800" height="500">
       
    </cfform>
  139. Calvin
    Sorry to be a bother, I'm new to the flash remoting world so please bare with me.

    Do you have a example of how to pass the values from a cfgrid to a cfc without using data binding on the cfgrid?


    I apologize if you have answered this before.
  140. Calvin
    Sorry to be a bother, I'm new to the flash remoting world so please bare with me.

    Do you have a example of how to pass the values from a cfgrid to a cfc without using data binding on the cfgrid?


    I apologize if you have answered this before.
  141. Nick
    For this example, it already has the flash built into the webpage. How can do EXACTLY this but instead, have it display as a .swf file?
  142. Pp
    some case cffunction must return different data type
    (query Or database error string)
    how i can check results type
  143. Kate Juliff
    Great site BTW.

    I have implemented this method. I can access the total row count returned from the query. But how can I add it to the page. Also my grid has a column with dollar amounts. Any way to total in the grid itself?
  144. James B. Rojas

    James B. Rojas

    Thanks for all the great information.

    I'm not sure if this has already been asked. I wanted to bind a CFGRID to a cfc in a flash form because I like the paging aspects. I wanted the CFGRID to populate on a post. Is this possible? Here is the code:

    <cfform name="tstTests" width="450" format="flash">
    :
    :
    <cfgrid name="tstGrid"
    height="200"
    format="HTML"
    preservePageOnSort="true"
       bind="cfc:Jobs.getAlltests({cfgridpage},{cfgridpagesize},{cfgridsortcolumn},{cfgridsortdirection})"
    sort="true"
       stripeRows="true"
       width="450">
       <cfgridcolumn name="Testcode" header="Test Code" width="200"/>
       <cfgridcolumn name="TestName" header="Test Name" width="200"/>
    </cfgrid>

    Thank you in advance.