Skip to main content
October 6, 2015
Answered

ColdFusion 8 to 11 CFGrid Method

  • October 6, 2015
  • 1 reply
  • 931 views

Hi,


I have a CFGrid which was working properly in ColdFusion 8 but after I upgrade my version to ColdFusion 11, the CFGrid does not update/rebind data after it's refresh button is being clicked. I have 4 inputs, a search button and a grid which is for searching module.


Below is part of my code:-

<script type="text/javascript" >

  

    getID = function(){

      

       if(document.thisform.usrID){         

           var usrID = ColdFusion.getElementValue('usrID');  

           alert(usrID);

              return usrID;

           }

    }

    getName = function(){

        if(document.thisform.name){

       var name = ColdFusion.getElementValue('name');

       return name;

        }

    }

  

    getDepart = function(){

        if(document.thisform.depart){

       var depart = ColdFusion.getElementValue('depart');

       return depart;

        }

    }

  

    getStatus = function(){

        if(document.thisform.status){

       var status = ColdFusion.getElementValue('status');

       return status;

        }

    }          

  

</script>


<cfform name="thisform" method="post">

        <cfoutput>

        <table width="79%"  align="left" border="0" class="MainContent">

            <tr>

                <td width="17%" ><cfoutput>#UsrID#</cfoutput> :</td>

              <td width="30%"><cfinput class="parfontinput" type="Text" name="usrID" maxlength="30" autosuggest="#ValueList(data.adm_authid)#"></td>

                <td width="18%" ><cfoutput>#UsrName#</cfoutput> :</td>           

              <td width="35%"><cfinput class="parfontinput" type="Text" name="name" maxlength="250" autosuggest="#ValueList(data.aut_name)#"></td>

            </tr>

            <tr>

                <td width="17%" ><cfoutput>#Depart#</cfoutput> :</td>

                <td>

                    <cfselect class="parfontinput" name="depart">

                        <option value="-1" selected>-- #DrpDown# --</option>

                            <cfloop query="department">

                                <option value="#cd_id#">#cd_desc#</option>

                            </cfloop>

                    </cfselect></td>

                 <td width="18%" ><cfoutput>#Status#</cfoutput> :</td>           

                  <td width="35%">

                    <cfselect class="parfontinput" name="status">

                        <option value="-1" selected>-- #DrpDown# --</option>

                            <cfloop query="sts">

                                <option value="#cd_id#">#cd_id# - #cd_desc#</option>

                            </cfloop>

              </cfselect></td>

            </tr>

            <tr>

                <td colspan="4"><br>

                    <cfinput id="button" type="button" name="submitBtn" value="#BtnSrch#" onClick="ColdFusion.Grid.refresh('userGrid');"

                    class="button2" style="width:80px"> 

                           </td>

            </tr>   

            <tr>

                <td colspan="4">                 </td>

            </tr>

        </table>

        </cfoutput>

    </cfform>

<cfform name="myForm" method="post" action="userForm.cfm">   

           

           

                <cfgrid name="userGrid"

                        format="html"

                        pagesize="10"

                        width="800"

                        preservePageOnSort="true"

                        bind="cfc:ipo.member.userCom.getAllUser({cfgridpage},{cfgridpagesize},{cfgridsortcolumn},{cfgridsortdirection},getID(),getName(),getDepart(),getStatus())"

                        sort="true"

                        stripeRows="true"

                        colheaderbold="yes" selectcolor="##CCCCCC" selectonload="false">

                       

                    <cfgridcolumn name="rownum"     header="#GridNo#"                 width="030">   

                    <cfgridcolumn name="adm_authid" header="#GridUserID#"             display="yes">

                    <cfgridcolumn name="aut_name"     header="#GridName#"                width="200"    display="yes">

                    <cfgridcolumn name="department" header="#GridDept#"             width="200"    display="yes">

                    <cfgridcolumn name="STATUS"     header="#GridStatus#"             width="150"    display="yes">

                    <cfgridcolumn name="See"         header="#GridView#"             width="050" display="yes">       

                </cfgrid>

            

            </cfform>

On page load (ColdFusion 11), the bind function runs normally and it executes the getID(), getName(), getDepart() and getStatus() function. After I filled in one of the fields, let's say depart and clicked the search button, it should search for department and display it on the grid. The problem is the bind function will run but it did not execute the getID(), getName(), getDepart() and getStatus() function. In ColdFusion 8, the code runs perfectly. Is there any workaround on this?

This topic has been closed for replies.
Correct answer

I found out the solution. I replaced the JavaScript functions with a proper parameters to the bind attributes.

From this :-

bind="cfc:ipo.member.userCom.getAllUser({cfgridpage},{cfgridpagesize},{cfgridsortcolumn},{cfgridsortdirection},getID(),getName(),getDepart(),getStatus())"


To this:-


bind="cfc:ipo.member.userCom.getAllUser({cfgridpage},{cfgridpagesize},{cfgridsortcolumn},{cfgridsortdirection},{usrID@submitBtn},{name@submitBtn},{depart@submitBtn},{status@submitBtn})"


{[control ID][@event]}


Where in this case, it will get the value from input usrID after submitBtn button has been clicked. Same goes for the others.

1 reply

Correct answer
October 9, 2015

I found out the solution. I replaced the JavaScript functions with a proper parameters to the bind attributes.

From this :-

bind="cfc:ipo.member.userCom.getAllUser({cfgridpage},{cfgridpagesize},{cfgridsortcolumn},{cfgridsortdirection},getID(),getName(),getDepart(),getStatus())"


To this:-


bind="cfc:ipo.member.userCom.getAllUser({cfgridpage},{cfgridpagesize},{cfgridsortcolumn},{cfgridsortdirection},{usrID@submitBtn},{name@submitBtn},{depart@submitBtn},{status@submitBtn})"


{[control ID][@event]}


Where in this case, it will get the value from input usrID after submitBtn button has been clicked. Same goes for the others.