CFFORM type=Flash, CFGRID type=Flash
Hello Everyone
Please correct me if I'm wrong, but it seems to me that few developers use flash as the format for both a cfform & cfgrid. I've discovered that there are several 'quarks' with this combination. I mean, I'm at my wits-end trying different variations of deleting a recod from a grid and from a session based array/structure combination. I prefer to use flash as the format for the entire form, but I cannot use the href & hrefKey attribute in an HTML grid if it's within a flash form.
Could someone give me some direction here. I have a flash form that saves form data to an array of structures. I populate the CFGRID with a CFINVOKE statement to get the data from the array (can't use a bind or query). I then have a delete checkbox in the grid that will delete the record from the grid (and array) with a popup message but I can't figure out how to delete the record from the array?
INDEX.CFM
<cfif
isDefined("Form.Submit")>
<!--- Add item to cart data --->
<cfinvoke component="FormData" method="Add" firstname="#form.firstname#" lastname="#form.lastname#">
</cfif>
<cfform
format="flash" name="myform" skin="haloBlue" style="background-color:##FAFAFA;" width="600" height="200">
<cfformitem
type="script">
function actionRemove(ID) {
var myClickHandler = function (evt){
if (evt.detail == mx.controls.Alert.OK){
var myAlert2 = mx.controls.Alert.show(ID + " Deleted", "Info", mx.controls.Alert.OK);
// code to delete the record from the array of structures
// call the remove method from the formdata.cfc
}
}
var myAlert = mx.controls.Alert.show("Are you sure you want to delete this?", "Warning", mx.controls.Alert.OK | mx.controls.Alert.CANCEL, this, myClickHandler);
}
</cfformitem>
<cfformgroup type="hbox">
<cfformgroup type="vbox">
<cfinput name="firstname" label="First Name:" type="text" />
<cfinput name="lastname" label="Last Name:" type="text" />
<cfformgroup type="horizontal">
<cfinput type="submit" value="Save Changes" name="submit">
<cfinput type="button" name="removeContact" value="Remove Checked" onClick="actionRemove(this.UserInfo.selectedItem.ID)" />
</cfformgroup>
</cfformgroup>
<cfformgroup type="vbox">
<!--- GRID DISPLAY --->
<cfinvoke method="list" component="FormData" returnvariable="qRet"></cfinvoke>
<cfgrid name="UserInfo" format="html" colheaderbold="Yes" font="Tahoma" rowHeaders="No" query="qRet" selectmode="edit">
<cfgridcolumn name="FIRSTNAME" header="First" display="true" select="false" />
<cfgridcolumn name="LASTNAME" header="Last" display="true" select="false" />
<cfgridcolumn name="checked" header="Delete" type="boolean" width="40" select="true" />
</cfgrid>
</cfformgroup>
</cfformgroup>
</cfform>
FORMDATA.CFC
<cfcomponent
output="false" access="public">
<!--- *** ADD Method *** --->
<
cffunction name="Add" access="public" returnType="void" output="false" hint="Adds data to the cart">
<cfargument name="firstname" type="String" required="Yes">
<cfargument name="lastname" type="String" required="Yes">
<cfset temp = arrayAppend(session.arrFormData, structNew())>
<cfset SESSION.arrFormData[arrayLen(SESSION.arrFormData)].firstname = arguments.firstname>
<cfset SESSION.arrFormData[arrayLen(SESSION.arrFormData)].lastname = arguments.lastname>
<cfset SESSION.arrFormData[arrayLen(SESSION.arrFormData)].checked = "false">
<cfset SESSION.arrFormData[arrayLen(SESSION.arrFormData)].id = arrayLen(session.arrFormData)>
</cffunction>
<!--- *** LIST Method *** --->
<cffunction name="List" access="remote" returnType="any" output="false" hint="Returns a query object containing all items in the array/structure.">
<cfargument name="page" default="1">
<cfargument name="pageSize" default="5">
<cfargument name="cfgridsortcolumn">
<cfargument name="cfgridsortdirection">
<!--- Create a query, to return to calling process --->
<cfset var q = queryNew("FIRSTNAME, LASTNAME, checked, ID")>
<!--- For each item in cart, add row to query --->
<
cfloop from=1 to="#arraylen(SESSION.arrFormData)#" index="i">
<cfset queryAddRow(q)>
<cfset querySetCell(q, "FIRSTNAME", SESSION.arrFormData.FIRSTNAME)>
<cfset querySetCell(q, "LASTNAME", SESSION.arrFormData.LASTNAME)>
<cfset querySetCell(q, "checked", SESSION.arrFormData.checked)>
<cfset querySetCell(q, "ID", SESSION.arrFormData.ID)>
</cfloop>
<!--- Return completed query --->
<cfreturn q>
</cffunction>
<!--- *** REMOVE Method *** --->
<cffunction name="Remove" access="remote" returnType="void" output="false" hint="Removes an item from the shopping cart">
<cfargument name="recID" type="numeric" required="Yes">
<cfset ArrayDeleteAt(SESSION.arrFormData, arguments.recID)>
</cffunction>
</cfcomponent>
Any help, suggestions or comments are GREATLY appreciated.
JK
