Populating a cfgrid with Flash Remoting
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>
CarlosM()
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!
Nahuel
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.
CarlosM()
It didn't occur to me that MyService.getDate(mask.text) is the string passed...:0 I had to take little bits.
Thank You
Paul Roe
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?
AndyC
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
Laura
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
AndyC
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
AndyC
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
Steve Walker
I would also like to cast my vote for a multi-function example.
AndyC
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
Steve Walker
Thank you. I will give it a try. I think I was making it too difficult.
Steve Walker
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 "smi"). 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
Steve Walker
Bob L.
Steve Walker
<cfformitem type="html" width="400"><cfoutput>#QueryName.RecordCount# Item(s) Listed</cfoutput></cfformitem>
Neil Bailey
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 "filtered", but DEFINITELY not afterwards...
Any ideas would be MUCH appreciated......
Nahuel
The problem with the mask is a bug in ColdFusion. They will fix that in the next release, Merrimack.
Nahuel
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)
Nahuel
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.
AndyC
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
Brendan Rehman
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>
Rick
Laura
Are you putting the variable in your form in a button?
<cfinput type="button" onclick="#GetActiveFolders#" ....>
Laura
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.
Frank Gerritse
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#">
David Brown
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: "Unsupported type found in stream". 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?
Laura
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 "Unsupported type...." 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.
andy
David D Brown
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?
Laura
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?
AndyC
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?
Jeff
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?
Nahuel
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.
Jeff
(single sql), it works fine.
Brent
Nahuel
We'll make and example of that once Merrimack goes out
Jeff
Neil Bailey
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...
Jeff
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 <i>myService = connection.getService("flashRemotingResponder", responseHandler ); </i> and change it to <i>myService = connection.getService("asfusion.flashRemotingResponder", responseHandler );</i>
Notice the "asfusion." 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.
John
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
Laura
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 "A couple of notes on Remoting" 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 < 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="true") and set onclick="GridData.insertRow(contactList);"
The same should be true for delete, but I am not sure why delete is not working with GridData.deleteRow(contactList); though.
Critter
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 "/" and call it via "flashRemotingResponder" then it works fine.. any suggestions? i'm lost.
Laura
Do you get an alert "Error while calling cfc:"...
do the folder pets have assets/com folder?
Are you able to browse
/projects/pets/assets/com/flashRemotingResponder.cfc?method=getDate
?
Critter
Jeff
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.
Critter
Critter
Critter
<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..
Critter
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
Laura
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 "include" the "page", 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
Happy Critter
i did catch the getItemAt issue.. /and/ setting the var lsPetFeedings = lsPetFeedings did sort that issue of nothing happening with the grid.
many thanks!
Chris
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 "undefined", 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
Laura
use {(myGrid.selectedItem!=undefined)? mygrid.selectedItem.myColumn : ''}
you can replace '' by a default if you want.
Chris
that didn't work for me either... still showed "undefined". Then I used value="" instead of the bind attribute, and still got "undefined"... then I realized that a value of "" 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
Melissa
Chris
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
Melissa
Chris
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:
"Branch between 40461 and 73233 around line 0 exceeds 32K span. If possible, please refactor this component."
I tried to include the <cfformitem> 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
Nahuel
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
Ryan F
The environtment is CF 7.01 running multiserver on iis6
Best regards,
Ryan
Javier Julio
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(""+grdPaperData.selectedIndex+" "+radScore.selectedRadio.data);
//when results return update cfgrid
grdPaperData.editField(grdPaperData.selectedIndex,"score",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.
Laura
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 "score". 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.
Thomary
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 -
<cfgridcolumn name="StartDate" header="Start" width="250" mask="mm/dd/yy">
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.
Thomary
DATE_FORMAT(queryname.fieldname, '%m-%d-%y') as name,
Select firstname, lastname, DATE_FORMAT(queryname.startdate, '%m-%d-%y') AS sdate, employeeid, ...
Michael Borbor
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?
Chris
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?
Chris
Laura
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.
Michael Borbor Sanchez
Laura
No, it is not possible to have a dropdown in a grid. You can do it with hacks, but I do not recommend them.
Michael Borbor
Ben
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
Laura
This should give you an idea of what to do:
http://www.asfusion.com/blog/entry/checkboxes-in-a-cfgrid
Tim
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)["prj_name"];
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
Tim
i wasnt seeing anything because no records were being returned.
here is what i used to debug it:
var mt_array = results;
var objString = "";
for(var i in mt_array){
objString += i + " = " + mt_array[i] + "\n";
}
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
John DeGrood
Pegarm
GrassHopper
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?
GrassHopper
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?
Jimmy
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.
Sandra
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.
George
Laura
this post should help you:
http://www.asfusion.com/blog/entry/knowing-when-the-cfform-data-arrives
Paul
Neil
Paul
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.
Laura
If that is your problem, then check this post:
http://www.asfusion.com/blog/entry/knowing-when-the-cfform-data-arrives
eatmorepossum
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.
eatmorepossum
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
Riz
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.
Riz
To all those with a similar issue I changed :
contactList.dataProvider[contactList.selectedIndex]['name'])
to
availList.selectedItem.name
Bradford
Laura
Check the case of your columns in your binding.
tj
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']);
}
}
Joseph Abenhaim
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!.
Laura
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
AHE
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.
AHE
Thanks in advance.
Ahmed.
Laura
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)
AHE
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.
AHE
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).
Kelly
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>
Laura
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)
Daryl
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.
Laura
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.
Daryl
Thank you very much. It's always something simple that eludes me :)
Robert
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?
Laura
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.
Robert
Tony Eckert
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?
Laura
Your question is such a frequently asked one that I added a note in the post.
Tony Eckert
Kelly
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>
}
Laura
Are you calling formOnLoad() in the onload attribute of cfform?
Kelly
Laura
Did you try hardcoding the variables in # signs manually? (I don't see any <cfoutput> tag around them)
Kelly
nel
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
Jason
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.
Laura
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.
Jason
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
Laura
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.
Justin
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
Carl
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>
Carl
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.
Laura
Interestingly, this post had a note about that after the first code segment ;)
Rodrigo
AuroraCF
Help please!!
Thanks,
Pn
Mark Cadle
myService = connection.getService("COMPONENT_NAME_HERE", responseHandler );
myService.myFunction();
}
Remember to use dot notation for path specification too!
AuroraCF
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
rudy750
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.
Brad
<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>
rudy750
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:
Brad
<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>
Brad
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!
rudy750
If you figure something out let me know! If you get stuck let me know
Brad
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.
William Green
<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?
shelts
Brad
kll57
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
Clayton
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>
Calvin
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.
Calvin
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.
Nick
Pp
(query Or database error string)
how i can check results type
Kate Juliff
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?
James B. Rojas
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.