|
Prev: Brand Watches Rado Ladies Watches Coupole R22550103 - AA Discount, Replica, Fake
Next: webservice timeout
From: cfwild on 18 Apr 2008 12:23 Hi, I'm trying to get a CFINPUT type = text box to hold the results of function (availableSpace). The function (held in a cfc) seems to be working ok, but it's not binding to the cfinput text box. I also want the text box information to update (onchange) when the grid is updated using the edit Status function. Any and all thoughts are welcome! cfwild Base Page (has the cfinput box): <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <html> <head> <title>Grid Filter Test</title> </head> <body> <cfwindow initshow="true" center="true" width="485" height="540" title="Grid Filter Test"> <cfform> <cfselect bind="cfc:brands2.getBrandsFilter()" bindonload="true" name="getBrandsFilter" values="Brand" Display="Brand" STYLE="Width: 436px;" /> <cfinput type="text" bind="cfc:brands2.availableSpace()" bindonload="true" name="availableSpace" value="ISUM" disabled="true" STYLE="Width: 436px; text-align: right;" /> <cfgrid name="artists" format="html" pagesize="17" striperows="yes" selectmode="edit" bind="cfc:brands2.getBrands({cfgridpage}, {cfgridpagesize}, {cfgridsortcolumn}, {cfgridsortdirection}, {getBrandsFilter(a)change})" onchange="cfc:brands2.editStatus({cfgridaction}, {cfgridrow}, {cfgridchanged})"> <cfgridcolumn name="UPC" display="No"/> <cfgridcolumn name="Brand" header="Brand" width="140" select="No"/> <cfgridcolumn name="Description" header="Description" width="175" select="No"/> <cfgridcolumn name="I" header="Status" width="120" values="2,1,3" valuesDisplay="Yes,No,Force"/> </cfgrid> </cfform> </cfwindow> </body> </html><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <html> <head> <title>Grid Filter Test</title> </head> <body> <cfwindow initshow="true" center="true" width="485" height="540" title="Grid Filter Test"> <cfform> <cfselect bind="cfc:brands2.getBrandsFilter()" bindonload="true" name="getBrandsFilter" values="Brand" Display="Brand" STYLE="Width: 436px;" /> <cfinput type="text" bind="cfc:brands2.availableSpace()" bindonload="true" name="availableSpace" value="ISUM" disabled="true" STYLE="Width: 436px; text-align: right;" /> <cfgrid name="artists" format="html" pagesize="17" striperows="yes" selectmode="edit" bind="cfc:brands2.getBrands({cfgridpage}, {cfgridpagesize}, {cfgridsortcolumn}, {cfgridsortdirection}, {getBrandsFilter(a)change})" onchange="cfc:brands2.editStatus({cfgridaction}, {cfgridrow}, {cfgridchanged})"> <cfgridcolumn name="UPC" display="No"/> <cfgridcolumn name="Brand" header="Brand" width="140" select="No"/> <cfgridcolumn name="Description" header="Description" width="175" select="No"/> <cfgridcolumn name="I" header="Status" width="120" values="2,1,3" valuesDisplay="Yes,No,Force"/> </cfgrid> </cfform> </cfwindow> </body> </html> cfc (availableSpace function is at the bottom): <cfcomponent output="false"> <CFSET DSN = ListRest(GetAuthUser())> <CFSET TP = SESSION.tablePrefix> <CFSET THIS.dsn="#DSN#"> <!--- Get Brands ---> <cffunction name="getBrands" access="remote" returntype="struct"> <cfargument name="page" type="numeric" required="yes"> <cfargument name="pageSize" type="numeric" required="yes"> <cfargument name="gridsortcolumn" type="string" required="no" default=""> <cfargument name="gridsortdir" type="string" required="no" default=""> <cfargument name="getBrandsFilter" type="string" required="no" default=""> <!--- Local variables ---> <cfset var brands=""> <!--- Get data ---> <cfquery name="brands" datasource="#THIS.dsn#"> SELECT #TP#_quadTable.UPC, #TP#_quadTable.Brand, #TP#_quadTable.Description, #TP#_quadTable.I FROM #TP#_quadTable <cfif ARGUMENTS.getBrandsFilter EQ "Brand Filter"> <cfelse> WHERE #TP#_quadTable.Brand = '#ARGUMENTS.getBrandsFilter#' </cfif> <cfif ARGUMENTS.gridsortcolumn NEQ "" and ARGUMENTS.gridsortdir NEQ ""> ORDER BY #ARGUMENTS.gridsortcolumn# #ARGUMENTS.gridsortdir# <cfelse> ORDER BY #TP#_quadTable.Brand </cfif> </cfquery> <!--- And return it as a grid structure ---> <cfreturn QueryConvertForGrid(brands, ARGUMENTS.page, ARGUMENTS.pageSize)> </cffunction> <!--- Get Brands Filter ---> <cffunction name="getBrandsFilter" access="remote"> <cfargument name="brand" type="string" required="no"> <!--- Local variables ---> <cfset var data=""> <!--- Get data ---> <cfquery name="data" datasource="#THIS.dsn#"> SELECT DISTINCT #TP#_quadTable.Brand FROM #TP#_quadTable; </cfquery> <!--- Add Blank Row (For No Filter) & Sort for CFSelect ---> <CFSET totalRows = (data.recordcount+1)> <CFSET getBrandsFilter = QueryNew("Brand", "VarChar")> <CFSET newRow = QueryAddRow(getBrandsFilter, totalRows)> <CFSET temp = QuerySetCell(getBrandsFilter, "Brand", "Brand Filter", 1)> <CFSET counter = 2> <CFLOOP QUERY="data"> <CFSET temp = QuerySetCell(getBrandsFilter, "Brand", Brand, counter)> <CFSET counter = counter+1> </CFLOOP> <!--- Return it to CFSelect for Grid Filter ---> <CFRETURN getBrandsFilter> </cffunction> <!--- Edit Brand Status ---> <cffunction name="editStatus" access="remote"> <cfargument name="gridaction" type="string" required="yes"> <cfargument name="gridrow" type="struct" required="yes"> <cfargument name="gridchanged" type="struct" required="yes"> <!--- Local variables ---> <cfset var value=""> <!--- Process gridaction ---> <cfswitch expression="#ARGUMENTS.gridaction#"> <!--- Process updates ---> <cfcase value="U"> <!--- Get column name and value ---> <cfset colname=StructKeyList(ARGUMENTS.gridchanged)> <cfset value=ARGUMENTS.gridchanged[colname]> <!--- Perform actual update ---> <cfquery datasource="#THIS.dsn#"> UPDATE #TP#_quadTable SET #colname# = '#value#' WHERE UPC = #ARGUMENTS.gridrow.UPC# </cfquery> </cfcase> </cfswitch> </cffunction> <cffunction name="availableSpace" access="remote"> <cfset var data=""> <cfquery name="data" datasource="#THIS.dsn#"> SELECT Sum([I]) AS ISUM FROM #TP#_quadTable; </cfquery> <cfreturn availableSpaceavaila> </cffunction> </cfcomponent>
From: cfwild on 21 Apr 2008 10:07
Hi, I worked through the function. Ultimately I was returning a query, instead of just the value I wanted. I also needed an argument so that when the grid changed, it would allow the bind to change/update. Here are the minor changes: Thanks! cfwild cfc: <cffunction name="availableSpace" access="remote"> <cfargument name="availableSpace" type="string" required="no"> <cfset var data=""> <cfquery name="data" datasource="#THIS.dsn#"> SELECT Sum([I]) AS ISUM FROM #TP#_quadTable; </cfquery> <CFSET availableSpace = QueryNew("ISUM", "VarChar")> <cfset counter = 1> <cfloop query="data"> <CFSET newRow = QueryAddRow(availableSpace)> <CFSET temp = QuerySetCell(availableSpace, "ISUM", ISUM, counter)> <cfset counter = counter+1> </CFLOOP> <CFSET space = availableSpace.ISUM> <cfreturn space> </cffunction> grid page: (changes): <cfinput type="text" bind="cfc:brands2.availableSpace({availableSpace(a)change})" value="space" bindonload="true" name="availableSpace" disabled="true" STYLE="Width: 436px; text-align: right;" /> |