0

I need to edit the values of one (or more) column in the cfgrid by double-clicking the value and on pressing enter the cfgrid should update the db with the new value.

I have seen this capability in the flex datagrid . A similar capability is expected.

Any help is appreciated.

James A Mohler
  • 11,060
  • 15
  • 46
  • 72
Yoosaf Abdulla
  • 3,722
  • 4
  • 31
  • 34

1 Answers1

0

I am newbie to CF so i finally found out how you do that: you need to add the attribute selectMode=edit and moreover you need to add the onchange attribute. eg: onchange = "cfc:getCalculatorData.editCategory({cfgridaction},{cfgridrow},{cfgridchanged})">

Further you write your update query in the cfc editLocation

Example for the cfc function is :

    <cfif isStruct(gridrow) and isStruct(gridchanged)>
        <cfif gridaction eq "U">
            <cfset colname=structkeylist(gridchanged)>
            <cfset value=structfind(gridchanged,#colname#)>
            <cfquery name="team" datasource="batcalc"> 
                UPDATE tbl_category SET <cfoutput>#colname#</cfoutput> = 
                    '<cfoutput>#value#</cfoutput>'
                WHERE category_id = <cfoutput>#gridrow.category_id#</cfoutput>
            </cfquery>
        <cfelse>
            <cfquery name="delCat" datasource="batcalc"> 
                DELETE FROM tbl_category 
                WHERE category_id = <cfoutput>#gridrow.category_id#
                    </cfoutput>
            </cfquery> 
        </cfif>
    </cfif>
</cffunction>
Yoosaf Abdulla
  • 3,722
  • 4
  • 31
  • 34