这适用于 mySQL 后端
在形式...
<cfselect name="to" size="1" bind="cfc:cfcs.messages.getOrganisations()" bindonload="yes" value="organisationID" display="organisationName" required="Yes">
</cfselect>
在氟氯化碳
<cffunction access="remote" name="getOrganisations" output="false" returntype="query" displayname="Get organisations list" hint="This method returns a list of organisations as a query.">
<cfquery name="getOrganisations" datasource='myData'>
SELECT organisationID, organisationName, acceptsReferral, metadataTemplate
FROM organisations
WHERE acceptsReferral
ORDER BY organisationName ASC;
</cfquery>
<cfreturn getOrganisations>
</cffunction>
但如果我尝试
<cffunction access="remote" name="getOrganisations" output="false" returntype="query" displayname="Get organisations list" hint="This method returns a list of organisations as a query.">
<cfquery name="getOrganisations" datasource='myData'>
SELECT '0' AS organisationID, 'Select' AS organisationName, false AS acceptsReferral, 0 AS metadataTemplate
FROM organisations
UNION
(SELECT organisationID, organisationName, acceptsReferral, metadataTemplate
FROM organisations
WHERE acceptsReferral
ORDER BY organisationName ASC)
</cfquery>
<cfreturn getOrganisations>
</cffunction>
尝试获取查询的选择前导行,我在 firebug 中收到此 AJAX 错误“JSON 序列化失败:无法将二进制数据序列化为 JSON。”
亨利的建议解决了上述问题,但我再次对下一点有点困惑,试图将两个选择联系起来。
这有效...
<cfselect name="attentionOf" size="1" bind="cfc:cfcs.messages.getOrganisationMembers({to})" bindonload="false" value="userID" display="name" required="No" queryPosition="below">
<option value="0">Select</option>
</cfselect>
...但是如果我尝试使用绑定字段传入 DSN,我会从中得到“错误解析绑定”
<cfselect name="attentionOf" size="1" bind="cfc:cfcs.messages.getOrganisationMembers({to}, 'mySqlData')" bindonload="false" value="userID" display="name" required="No" queryPosition="below">
<option value="0">Select</option>
</cfselect>