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 %26amp; 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 %26amp; 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
%26lt;cfif
isDefined(''Form.Submit'')%26gt;
%26lt;!--- Add item to cart data ---%26gt;
%26lt;cfinvoke component=''FormData'' method=''Add'' firstname=''#form.firstname#'' lastname=''#form.lastname#''%26gt; %26lt;/cfif%26gt;
%26lt;cfform
format=''flash'' name=''myform'' skin=''haloBlue'' style=''background-color:##FAFAFA;'' width=''600'' height=''200''%26gt;
%26lt;cfformitem
type=''script''%26gt; 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); } %26lt;/cfformitem%26gt;
%26lt;cfformgroup type=''hbox''%26gt;
%26lt;cfformgroup type=''vbox''%26gt;
%26lt;cfinput name=''firstname'' label=''First Name:'' type=''text'' /%26gt;
%26lt;cfinput name=''lastname'' label=''Last Name:'' type=''text'' /%26gt;
%26lt;cfformgroup type=''horizontal''%26gt;
%26lt;cfinput type=''submit'' value=''Save Changes'' name=''submit''%26gt;
%26lt;cfinput type=''button'' name=''removeContact'' value=''Remove Checked'' onClick=''actionRemove(this.UserInfo.selectedItem.ID)'' /%26gt;
%26lt;/cfformgroup%26gt;
%26lt;/cfformgroup%26gt;
%26lt;cfformgroup type=''vbox''%26gt;
%26lt;!--- GRID DISPLAY ---%26gt;
%26lt;cfinvoke method=''list'' component=''FormData'' returnvariable=''qRet''%26gt;%26lt;/cfinvoke%26gt;
%26lt;cfgrid name=''UserInfo'' format=''html'' colheaderbold=''Yes'' font=''Tahoma'' rowHeaders=''No'' query=''qRet'' selectmode=''edit''%26gt;
%26lt;cfgridcolumn name=''FIRSTNAME'' header=''First'' display=''true'' select=''false'' /%26gt;
%26lt;cfgridcolumn name=''LASTNAME'' header=''Last'' display=''true'' select=''false'' /%26gt;
%26lt;cfgridcolumn name=''checked'' header=''Delete'' type=''boolean'' width=''40'' select=''true'' /%26gt;
%26lt;/cfgrid%26gt;
%26lt;/cfformgroup%26gt;
%26lt;/cfformgroup%26gt; %26lt;/cfform%26gt;
FORMDATA.CFC
%26lt;cfcomponent
output=''false'' access=''public''%26gt;
%26lt;!--- *** ADD Method *** ---%26gt;
%26lt;
cffunction name=''Add'' access=''public'' returnType=''void'' output=''false'' hint=''Adds data to the cart''%26gt;
%26lt;cfargument name=''firstname'' type=''String'' required=''Yes''%26gt;
%26lt;cfargument name=''lastname'' type=''String'' required=''Yes''%26gt;
%26lt;cfset temp = arrayAppend(session.arrFormData, structNew())%26gt;
%26lt;cfset SESSION.arrFormData[arrayLen(SESSION.arrFormData)].firstname = arguments.firstname%26gt;
%26lt;cfset SESSION.arrFormData[arrayLen(SESSION.arrFormData)].lastname = arguments.lastname%26gt;
%26lt;cfset SESSION.arrFormData[arrayLen(SESSION.arrFormData)].checked = ''false''%26gt;
%26lt;cfset SESSION.arrFormData[arrayLen(SESSION.arrFormData)].id = arrayLen(session.arrFormData)%26gt;
%26lt;/cffunction%26gt;
%26lt;!--- *** LIST Method *** ---%26gt;
%26lt;cffunction name=''List'' access=''remote'' returnType=''any'' output=''false'' hint=''Returns a query object containing all items in the array/structure.''%26gt;
%26lt;cfargument name=''page'' default=''1''%26gt;
%26lt;cfargument name=''pageSize'' default=''5''%26gt;
%26lt;cfargument name=''cfgridsortcolumn''%26gt;
%26lt;cfargument name=''cfgridsortdirection''%26gt;
%26lt;!--- Create a query, to return to calling process ---%26gt;
%26lt;cfset var q = queryNew(''FIRSTNAME, LASTNAME, checked, ID'')%26gt;
%26lt;!--- For each item in cart, add row to query ---%26gt;
%26lt;
cfloop from=1 to=''#arraylen(SESSION.arrFormData)#'' index=''i''%26gt;
%26lt;cfset queryAddRow(q)%26gt;
%26lt;cfset querySetCell(q, ''FIRSTNAME'', SESSION.arrFormData[i].FIRSTNAME)%26gt;
%26lt;cfset querySetCell(q, ''LASTNAME'', SESSION.arrFormData[i].LASTNAME)%26gt;
%26lt;cfset querySetCell(q, ''checked'', SESSION.arrFormData[i].checked)%26gt;
%26lt;cfset querySetCell(q, ''ID'', SESSION.arrFormData[i].ID)%26gt;
%26lt;/cfloop%26gt;
%26lt;!--- Return completed query ---%26gt;
%26lt;cfreturn q%26gt;
%26lt;/cffunction%26gt;
%26lt;!--- *** REMOVE Method *** ---%26gt;
%26lt;cffunction name=''Remove'' access=''remote'' returnType=''void'' output=''false'' hint=''Removes an item from the shopping cart''%26gt;
%26lt;cfargument name=''recID'' type=''numeric'' required=''Yes''%26gt;
%26lt;cfset ArrayDeleteAt(SESSION.arrFormData, arguments.recID)%26gt;
%26lt;/cffunction%26gt;
%26lt;/cfcomponent%26gt;
Any help, suggestions or comments are GREATLY appreciated.
JK
CFFORM type=Flash, CFGRID type=Flash Please correct me if I'm wrong, but it seems to me that few developers use flash as the format for both a cfform %26amp; cfgrid.
No comments:
Post a Comment