Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>In my example, I have a set of drop downs that are tiered dependent (Coldbox 3.5+, CF9)</p> <p>Using bindCFC and cfajax , here is an example of the first two drop downs the second being dependent</p> <p><strong>My view snippet</strong></p> <pre><code>&lt;cfform&gt; &lt;cfselect name="groups" id="groups" bind="cfc:#getSetting('AppMapping')#.model.dynform.getGroups()" bindOnLoad="Yes" display="group_name" value="group_id" /&gt; &lt;cfselect name="events" id="events" selected="#form.event_id#" bind="cfc:#getSetting('AppMapping')#.model.dynform.getEventsByGroup({groups})" display="event_name" value="event_id" queryPosition="below"&gt; &lt;/cfform&gt; </code></pre> <p><strong>My model (dynform) snippet</strong></p> <pre><code>&lt;cffunction name="getGroups" access="remote" output="false" returntype="query"&gt; &lt;cfset var qGroups = ""&gt; &lt;cfquery datasource="#application.DSN#" name="qGroups"&gt; SELECT egc.nd_event_group_id group_id, egc.short_desc group_name FROM event_group_code egc WHERE egc.status_code = 'A' ORDER BY egc.sort_order &lt;/cfquery&gt; &lt;cfreturn qGroups&gt; &lt;/cffunction&gt; &lt;cffunction name="getEventsByGroup" access="remote" output="false" returntype="query"&gt; &lt;cfargument name="event_group_id" type="string" required="true"&gt; &lt;cfset var qEventsByGroup = ""&gt; &lt;cfquery datasource="#application.DSN#" name="qEventsByGroup"&gt; SELECT ec.event_id, ec.FULL_DESC as event_name FROM events ec WHERE ec.event_group_id = &lt;cfqueryparam cfsqltype="cf_sql_varchar" value="#arguments.event_group_id#"&gt; &lt;/cfquery&gt; &lt;cfreturn qEventsByGroup&gt; &lt;/cffunction&gt; </code></pre> <p>Though the above will work, I ended up ditching it for the jQuery/ajax return JSON approach. The reasons why:</p> <ol> <li><p>Coldbox way = Handlers should be doing the work, not views</p></li> <li><p>CFajax/cfselect was slower than jQuery ajax, and with less options. (What if I want a multiple select box? Or three data attributes returned rather than two?)</p></li> <li><p>I didn't want to use the cfform tag in my view, which cfselect requires</p></li> </ol> <p>I can post the jQuery ajax way if needed, but I think I answered the original question</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload