The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.
|
 |
|
Dev Shed Forums
> Programming Languages - More
> ColdFusion Development
|
Display Grid based on Listbox item selected
Discuss Display Grid based on Listbox item selected in the ColdFusion Development forum on Dev Shed. Display Grid based on Listbox item selected ColdFusion Development forum discussing CFML coding practices, tips on CFML, and other CFML related topics. Find out why ColdFusion is the tool of choice for many e-commerce developers.
|
|
 |
|
|
|
|
|

Dev Shed Forums Sponsor:
|
|
|

June 1st, 2011, 03:52 PM
|
|
Contributing User
|
|
Join Date: Jun 2011
Posts: 60
Time spent in forums: 13 h 22 m 2 sec
Reputation Power: 2
|
|
|
Display Grid based on Listbox item selected
Hi Experts ,
i am really stuck on this one i need anexample urgently.
I have list of projects and their related information.
I need to have the list of project in a listbox and once i select a specific project .., a cfgrid will populate automaticallly the information related on the project selected.
Any help would be very appreciated.
thanks
|

June 1st, 2011, 10:36 PM
|
|
Moderator
|
|
Join Date: Jun 2002
Location: Raleigh, NC
|
|
If you have a cfselect like this:
Code:
<b>Projects:</b> <cfselect bind="cfc:projectService.getProjects()" bindonload="true" value="projectid" display="projectname" name="project" />
You can trigger a cfgrid to update based on the selection by setting a bind expression like:
Code:
bind="cfc:projectService.getProjectData( {cfgridpage}, {cfgridpagesize}, {cfgridsortcolumn}, {cfgridsortdirection}, {project} )"
See the CF docs for full and lengthy explanations of how the AJAX controls and binding expressions work.
|

June 2nd, 2011, 09:04 AM
|
|
Contributing User
|
|
Join Date: Jun 2011
Posts: 60
Time spent in forums: 13 h 22 m 2 sec
Reputation Power: 2
|
|
Hi Kitless,
Thanks for the quick reply. i ll try this one and get back to you. Is there a way to send you direct emails if i need any help ?
thanks a lot
Quote: | Originally Posted by kiteless If you have a cfselect like this:
Code:
<b>Projects:</b> <cfselect bind="cfc:projectService.getProjects()" bindonload="true" value="projectid" display="projectname" name="project" />
You can trigger a cfgrid to update based on the selection by setting a bind expression like:
Code:
bind="cfc:projectService.getProjectData( {cfgridpage}, {cfgridpagesize}, {cfgridsortcolumn}, {cfgridsortdirection}, {project} )"
See the CF docs for full and lengthy explanations of how the AJAX controls and binding expressions work. |
|

June 2nd, 2011, 10:55 AM
|
|
Contributing User
|
|
Join Date: Jun 2011
Posts: 60
Time spent in forums: 13 h 22 m 2 sec
Reputation Power: 2
|
|
|
Hi,
Iam still lost with grid trigger expression.are you able to provide me with simple examle. please this is very urgent for me ?
Thanks a lot
|

June 2nd, 2011, 11:23 AM
|
|
Moderator
|
|
Join Date: Jun 2002
Location: Raleigh, NC
|
|
|
Sorry, but I don't have the time to actually write up an example just for you. There are lots of examples of using binding both in the docs and via Google. Probably not describing your exact requirement but it should be enough for you to build off of.
|

June 2nd, 2011, 09:42 PM
|
|
Contributing User
|
|
Join Date: Jun 2011
Posts: 60
Time spent in forums: 13 h 22 m 2 sec
Reputation Power: 2
|
|
hi kiteless ,
sory to bother still experiencing the same issue here are my codes :
cfc function :
<cffunction name="getProjects" access="remote">
<cfargument name="page" required="yes">
<cfargument name="pageSize" required="yes">
<cfargument name="gridsortcolumn" required="yes">
<cfargument name="gridsortdirection" required="yes">
<cfquery name="q1" datasource="ORA1">
SELECT DISTINCT PROGRAMID,PROGRAMNAME,PROGRAMTYPE FROM PROGRAM
ORDER BY PROGRAMID
</cfquery>
<cfreturn queryconvertforgrid(members,page,pagesize)/>
</cffunction>
and here my cfm file :
<cfform name="form1">
Projects:</b> <cfselect bind="cfc:data1.getProjects()" bindonload="yes" value="PROGRAMID" display="PROGRAMNAME" name="project" /><br/>
<cfgrid format="html" name="grid_Tables" pagesize="7" selectmode="row"
bind="cfc:data1.getProjects({cfgridpage},{cfgridpagesize},{cfgridsortcolumn},{cfgridsortdirection},{projec t})">
<cfgridcolumn name="PROGRAMID" display="yes"/>
<cfgridcolumn name="PROGRAMNAME" header="PROGRAMNAME" >
<cfgridcolumn name="PROGRAMTYPE" header="PROGRAMTYPE" >
</cfgrid>
</cfform>
-----------
i am getting the following error :
You cannot specify more arguments to a CFC function than it declares.
this can change if i remove {project form the cfgrid bing argument.
the how can i trigger the cfgrid from the dropdown ?
thanks

|

June 3rd, 2011, 07:52 AM
|
|
Moderator
|
|
Join Date: Jun 2002
Location: Raleigh, NC
|
|
|
Your getProjects() method does not have an argument for the programId, but you are trying to pass it in from your grid's binding statement.
You need two CFC methods, one to get all the projects (for the list), and one to get just the data for one project (for the grid).
|

June 11th, 2011, 05:21 AM
|
|
Registered User
|
|
Join Date: Jun 2011
Posts: 1
Time spent in forums: 10 m 8 sec
Reputation Power: 0
|
|
|
hey
hey hello how are you i will send you the email may you should have it i wana know if its help full to you
|

June 11th, 2011, 01:14 PM
|
|
Contributing User
|
|
Join Date: Jun 2011
Posts: 60
Time spent in forums: 13 h 22 m 2 sec
Reputation Power: 2
|
|
Hi , thanks
Iam still stuck as iam using cf mx 7 and it does not have bind syntax
Do you have any alternate options whithout bind
Thanks.
Quote: | Originally Posted by Diyroberts hey hello how are you i will send you the email may you should have it i wana know if its help full to you |
|

June 11th, 2011, 03:03 PM
|
|
Moderator
|
|
Join Date: Jun 2002
Location: Raleigh, NC
|
|
Then you'll have to use something like jQuery to make the AJAX calls and update the client DOM.
|

June 11th, 2011, 03:38 PM
|
|
Contributing User
|
|
Join Date: Jun 2011
Posts: 60
Time spent in forums: 13 h 22 m 2 sec
Reputation Power: 2
|
|
Hi Kiteless ,
that what i am trying to do basically. Iwas able to pass the query into a CF array ..now i would like to pass the CF array to a Javascript array.
Any idea how to do this ?
thanks
Quote: | Originally Posted by kiteless Then you'll have to use something like jQuery to make the AJAX calls and update the client DOM. |
|

June 11th, 2011, 05:14 PM
|
|
Moderator
|
|
Join Date: Jun 2002
Location: Raleigh, NC
|
|
CF runs on the server, and JavaScript runs on the client. So you can't "pass" anything between CF and JavaScript. You need to make an HTTP request (typically an AJAX request) from the client's browser to the server in order to move any data between the two. You can find numerous examples of using CF and jQuery online, such as this.
Do you actually understand what AJAX is and what jQuery does? If not, you're going to have to read through a book, the jQuery documentation, or go through some of the many online examples. There are entire books written about AJAX, so it isn't something that you're going to get an answer to in a forum post. The breadth of the topic is much to large.
|

June 11th, 2011, 05:36 PM
|
|
Contributing User
|
|
Join Date: Jun 2011
Posts: 60
Time spent in forums: 13 h 22 m 2 sec
Reputation Power: 2
|
|
|
Hi Robert,
thanks for the guidance.
i have basically written the follwing code but not reaaaly working. I am sure this will do what i am expecting to see.
can you double check it please : Actually this code getscfquery into java array and the funcmtion onchange will just pass the JVS variable to the textbox.. not sure what is actually missing in the code ..i am geting my dropdownlist but the corresponding value does not show into textbox..
hre is my code :
[code]
<cfquery name="RecordsetUpdate" datasource="ORA1">
SELECT PROGRAMID,PROGRAMNAME,PROGRAMTYPE
FROM LAYACHMO.PROGRAM
</cfquery>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<cfoutput>
<script language="JavaScript">
//store array for addresses
var rec_count = #RecordsetUpdate.recordCount#;
var PROGRAMID = new Array(rec_count);
var PROGRAMNAME = new Array(rec_count);
var PROGRAMTYPE = new Array(rec_count);
<cfset count = 0>
<cfloop query="RecordsetUpdate">
PROGRAMID[#count#]= "#PROGRAMID#";
PROGRAMNAME[#count#]= "#PROGRAMNAME#";
PROGRAMTYPE[#count#]= "#PROGRAMTYPE#";
<cfset count = count +1>
</cfloop>
</cfoutput>
//Now the function that is caused by an onchange() from a select box
//JS event:
function changeAddress(obj){
var j = obj.selectedIndex - 1;
with (document.form1)
{
document.form1.PROGRAMID.value = PROGRAMID[j];
document.form1.PROGRAMNAME.value = PROGRAMNAME[j];
document.form1.PROGRAMTYPE.value = PROGRAMTYPE[j] ;
}
}
</script>
<form name="form1" >
<select name="RecordsetUpdate" onchange="changeAddress(this)">
<option value="">Select One ...
<cfif RecordsetUpdate.recordCount gt 0>
<cfoutput query="RecordsetUpdate">
<option value="#PROGRAMID#">#PROGRAMNAME#
</cfoutput>
</cfif>
</select>
<br><br><br><br>
<input type="text" name="PROGRAMTYPE" value="">
<!---<input type="text" name="lastname" value="">--->
</form>
</body>
</html>
|

June 11th, 2011, 06:12 PM
|
|
Moderator
|
|
Join Date: Jun 2002
Location: Raleigh, NC
|
|
|
Saying it is "not really working" doesn't help at all. What is the actual problem? Have you tried debugging your JavaScript with Firebug to see if there are any errors?
|

June 11th, 2011, 09:37 PM
|
|
Contributing User
|
|
Join Date: Jun 2011
Posts: 60
Time spent in forums: 13 h 22 m 2 sec
Reputation Power: 2
|
|
hi ,
The only part i could not test is the following :
function changeAddress(obj){
var j = obj.selectedIndex - 1;
with (document.form1)
{
document.form1.PROGRAMID.value = PROGRAMID[j];
document.form1.PROGRAMNAME.value = PROGRAMNAME[j];
document.form1.PROGRAMTYPE.value = PROGRAMTYPE[j] ;
}
i am not sure how to go through the form1 and pass variables to textfields. it seems not working with var j = obj.selectIndex -1;
thought /?
Quote: | Originally Posted by kiteless Saying it is "not really working" doesn't help at all. What is the actual problem? Have you tried debugging your JavaScript with Firebug to see if there are any errors? |
|
Developer Shed Advertisers and Affiliates
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Rate This Thread |
Linear Mode
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|