如何将 CFC 直接绑定到选择菜单?
我正在尝试创建一个选择菜单,可以在其中选择一个部门,然后选择该部门的员工。相关选择...
好吧,问题是...我需要直接绑定到 cfc,因为像这样的绑定:
<cfselect name="people" bind = "cfc:test.getPeople({department.value})" />
确实不工作。它什么也没做...这是部门的样子:
<cfselect name="department"
query="getDepartments"
display="deptname"
value="deptcode"
queryPosition = "below">
<option value = "">Select a Department</option>
</cfselect>
这里是 cfc:
<cfcomponent>
<cfset THIS.dsn="sqlProd_faculty_db">
<!--- Get art by media type --->
<cffunction name="getPeople" access="remote" returnType="query" >
<cfargument name="dcode" type="any" required="true">
<!--- Define variables --->
<cfset var data="">
<!--- Get data --->
<cfquery name="data" datasource="#THIS.dsn#">
SELECT b.LastName + ', ' + b.FirstName AS FullName, p.IDNum FROM faculty.dbo.SACS_Person p, faculty.dbo.budPerson
b WHERE p.DeptCode = '#arguments.dcode#' AND p.IDNum = b.ID ORDER BY b.LastName,
b.FirstName
</cfquery>
<!--- And return it --->
<cfreturn data>
</cffunction>
</cfcomponent>
我尝试这样做:
<cfselect name="people"
bind = "url:test.cfc?method=getPeople&returnFormat=json&dcode={department.value}"
display = "FullName" value = "IDNum"
BindOnLoad = "true" />
但这不起作用...出现解析错误..
Error parsing JSON response:
<script language="javascript">
<!--
document.onkeydown = catchKey;
step1 = 0;
step2 = 0;
function catchKey(e){
if(window.event.keyCode == 17){
step1 = 1;
}
if(window.event.keyCode == 18){
step2 = 1;
}
if(window.event.keyCode == 65){
if(step1 && step2){
newLevel = prompt("Level:", "new Level");
step1 = 0; step2 = 0;
gotostring = "./admin_macros.cfm?NewLevel=" + newLevel + "&Action=LevelChange";
window.location = gotostring;
}
}
}
-->
</script>
{"COLUMNS":["FULLNAME","IDNUM"],"DATA":[]} [Enable debugging by adding 'cfdebug' to your URL parameters to see more information]
I'm trying to create a select menu where one can select a department and then select employees in that department. Related Selects...
Ok here is the problem...I need to bind directly to the cfc because binding like this:
<cfselect name="people" bind = "cfc:test.getPeople({department.value})" />
DOES NOT WORK. It does nothing... here is what deparment looks like:
<cfselect name="department"
query="getDepartments"
display="deptname"
value="deptcode"
queryPosition = "below">
<option value = "">Select a Department</option>
</cfselect>
and here the cfc:
<cfcomponent>
<cfset THIS.dsn="sqlProd_faculty_db">
<!--- Get art by media type --->
<cffunction name="getPeople" access="remote" returnType="query" >
<cfargument name="dcode" type="any" required="true">
<!--- Define variables --->
<cfset var data="">
<!--- Get data --->
<cfquery name="data" datasource="#THIS.dsn#">
SELECT b.LastName + ', ' + b.FirstName AS FullName, p.IDNum FROM faculty.dbo.SACS_Person p, faculty.dbo.budPerson
b WHERE p.DeptCode = '#arguments.dcode#' AND p.IDNum = b.ID ORDER BY b.LastName,
b.FirstName
</cfquery>
<!--- And return it --->
<cfreturn data>
</cffunction>
</cfcomponent>
I tried doing it like this:
<cfselect name="people"
bind = "url:test.cfc?method=getPeople&returnFormat=json&dcode={department.value}"
display = "FullName" value = "IDNum"
BindOnLoad = "true" />
But that didn't work... get a parsing error..
Error parsing JSON response:
<script language="javascript">
<!--
document.onkeydown = catchKey;
step1 = 0;
step2 = 0;
function catchKey(e){
if(window.event.keyCode == 17){
step1 = 1;
}
if(window.event.keyCode == 18){
step2 = 1;
}
if(window.event.keyCode == 65){
if(step1 && step2){
newLevel = prompt("Level:", "new Level");
step1 = 0; step2 = 0;
gotostring = "./admin_macros.cfm?NewLevel=" + newLevel + "&Action=LevelChange";
window.location = gotostring;
}
}
}
-->
</script>
{"COLUMNS":["FULLNAME","IDNUM"],"DATA":[]} [Enable debugging by adding 'cfdebug' to your URL parameters to see more information]
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
除非提交,否则该表单没有定义department.value,因此您的绑定将不起作用。请将您的第二个 cfselect(employee) 放置在 cflayout 中,并在“部门”cfselect 的 onchange 事件中将表单提交到布局。您可以使用 ColdFusio.navigate() 方法将部门表单提交到员工布局上。
The form does not have the department.value defined unless it is submitted and hence your bind will not work. Please have your second cfselect(employee) placed in a cflayout and have in your onchange event of the 'department' cfselect to submit the form to the layout. You can use the coldFusio.navigate() method to submit your depart ment form onto the employee layout.