0 Replies Latest reply on Mar 11, 2008 1:09 PM by TomD__

    CFGrid pre-populating CFSelect In CF8

    TomD__
      I am somewhat new to ColdFusion (especially CF8 and AJAX) but have learned quite a bit recently. I have been racking my brain trying to find a solution or methodoly to this simple task.

      I am using CF8 and have created a cfgrid which is populated by a cfc (using the example in Ben & Ray's new WACK book). The grid should not allow editing. This works fine. My next goal was to have a series of cfinputs and cfselects bound to this grid that would display under the grid to allow for editing. There obviously is no problem binding the cfinput to the cfgrid. The problem that I'm running into is binding the cfselect to the the cfgrid.

      In CF8, the bind in cfselect allows you to bind to an array of valid inputs. What I'm trying to accomplish is having the initial value of the cfselect (or selected value) be the corresponding row selected in the cfgrid. In other words, if you select another row on the cfgrid, all values in the edit screen are updated, including the cfselect. Right now, only the cfinput tags are updated when the active row on the cfgrid is changed.

      I tried playing with onchange, cfproxy, options in cfselect, etc.but seem to have hit a brick wall. Does anyone know of any solutions?

      Thanks in advance.





      <cfform name="MainIndex"
      format="html"
      action="portalcfc.cfc?method=indexSelect">

      <cfgrid name="contact_grid"
      format="html"
      pagesize="10"
      striperows="yes"
      bind="cfc:portalcfc.browse({cfgridpage},
      {cfgridpagesize},
      {cfgridsortcolumn},
      {cfgridsortdirection})">

      <cfgridcolumn name="OBJECT_ID"
      width="100"
      header="Object ID">

      <cfgridcolumn name="CONTACT_NUMBER_CODE"
      width="100"
      select="yes"
      header="Contact Type">

      <cfgridcolumn name="CONTACT_NAME"
      width="100"
      header="Contact Name">

      <cfgridcolumn name="CONTACT_NUMBER"
      width="100"
      header="Contact Number">

      <cfgridcolumn name="EMAIL_ADDRESS"
      width="100"
      header="Email Address">

      <cfgridcolumn name="EMERGENCY_BROADCAST"
      width="100"
      header="Emergency Broadcast">

      </cfgrid>

      <cfinput type="text"
      name="OBJECT_ID"
      label="Object ID"
      bind="{contact_grid.OBJECT_ID}">

      <cfselect name="CONTACT_NUMBER_CODE"
      label="Contact Type"
      id="CONTACT_NUMBER_CODE"
      value="CONTACT_NUMBER_CODE"
      bind="cfc:portalcfc.getContactNumberCode()"
      bindonload="true">

      <!---
      <option value = ""></option>
      <option value = "Home">Home Telephone</option>
      <option value = "Mother">Mothers Telephone</option>
      <option value = "Father">Fathers Telephone</option>
      <option value = "Guardian">Guardian Telephone</option>
      <option value = "MWork">Mothers Work</option>
      <option value = "FWork">Fathers Work</option>
      <option value = "GWork">Guardian's Work</option>
      <option value = "MCell">Mothers Cell</option>
      <option value = "FCell">Fathers Cell</option>
      <option value = "GCell">Guardian's Cell</option>
      <option value = "Emerg">Emergency Telephone</option>
      <option value = "Emerg2">Emergency Telephone 2</option>
      <option value = "Emerg3">Emergency Telephone 3</option>
      <option value = "Emerg4">Emergency Telephone 4</option>
      <option value = "Emerg5">Emergency Telephone 5</option>
      <option value = "Emerg6">Emergency Telephone 6</option>
      <option value = "Emerg7">Emergency Telephone 7</option>
      <option value = "FPager">Fathers Pager</option>
      <option value = "MPager">Mothers Pager</option>
      <option value = "Dentist">Dentist</option>
      <option value = "Doctor">Doctor</option>
      <option value = "Hospital">Hospital</option>
      --->

      </cfselect>
      <cfset EMERGENCY_BROADCAST_BI = "Y">

      <cfinput type="text"
      name="CONTACT_NAME"
      label="Contact Name"
      validateAt="onSubmit"
      bind="{contact_grid.CONTACT_NAME}">

      <cfinput type="text"
      name="CONTACT_NUMBER"
      label="Contact Number"
      validateAt="onSubmit"
      bind="{contact_grid.CONTACT_NUMBER}">

      <cfinput type="text"
      name="EMAIL_ADDRESS"
      label="Email Address"
      validateAt="onSubmit"
      bind="{contact_grid.EMAIL_ADDRESS}">

      <cfselect name="EMERGENCY_BROADCAST"
      label="Emergency Broadcast">
      <option value = ""></option>
      <option value = "N" <cfif form.contact_grid.EMERGENCY_BROADCAST eq "N">selected="selected"</cfif>No</option>
      <option value = "Y" <cfif form.contact_grid.EMERGENCY_BROADCAST eq "Y">selected="selected"</cfif>Yes</option>
      </cfselect>


      <cfinput type="button"
      onclick="return ValidateFields()"
      name="contactOperation"
      value="Save">

      </cfform>