Skip to main content
Participant
August 13, 2007
Question

cfgrid and binding checkboxes

  • August 13, 2007
  • 1 reply
  • 1070 views
Hello,

I have about 10 checkboxes that I would like to show as checked or unchecked in a cfform. The cfgrid does not need to show the checkboxes. So I have 3 columns in my cfgrid (firstName,lastName,company) these all bind just fine to cfinput type="text". There are 10 bit/boolean columns in the same database table that I need binded to my form. When I selected a record the forms update fine with the following code.

<cfinput type="text" name="firstname" label="First"
bind="{membersGrid.dataProvider[membersGrid.selectedIndex]['FirstName']}"
onChange="membersGrid.dataProvider.editField(membersGrid.selectedIndex, 'FIRSTNAME', firstname.text);">


But when trying to do something similiar for a cfinput type of checkbox I get no where.

Any assistance would be greatly appreciated.

Thanks,

Ryan
    This topic has been closed for replies.

    1 reply

    existdissolve
    Inspiring
    August 25, 2007
    Try this:

    <cfsavecontent variable="change">
    if (myGrid.selectedItem.active == 0 ) {
    myCheckBox1.selected = false;
    }
    else {
    myCheckBox1.selected = true;
    }
    </cfsavecontent>

    <cfform name="myForm" format="flash" height="500">
    <cfgrid name="myGrid" query="rsMyQuery" onchange="#change#">
    <cfgridcolumn name="field1" display="yes">
    <cfgridcolumn name="myCheckBox1" display="no">
    </cfgrid>

    <cfinput type="text" name="field1" bind="{myGrid.selectedItem.field1}">
    <cfinput type="checkbox" name="myCheckBox1" checked="no" value="0" label="myCheckBox1">
    </cfform>

    Then obviously you can spawn the logic for each additional checkbox in the same onchange event.

    Hope this helps.

    Joel