-
1. Re: [Sorting not working] with CFGRID + Binding
BKBK Mar 13, 2011 8:07 AM (in response to fabio.bozzo)My thinking is that it has nothing to do with cfgrid, and everything to do with cfqueryparam binding. Run the following code on a test page, and you will see what I mean:
<cfset col = "someColumnName">
<cfset sort = "desc"><cfquery name="qryProducts" datasource="yourDSN" result="result">
SELECT * FROM articoli
ORDER BY
<cfqueryparam cfsqltype="cf_sql_varchar" value="#col#">
<cfqueryparam cfsqltype="cf_sql_varchar" value="#sort#">
</cfquery><cfdump var = "#result#">
The SQL that ColdFusion sends to the database server at compile-time is "SELECT * FROM articoli ORDER BY ? ?", plus instructions to use 'someColumnName' and 'desc' as the respective input parameters.
-
2. Re: [Sorting not working] with CFGRID + Binding
Adam Cameron. Mar 13, 2011 8:10 AM (in response to BKBK)You're right.
CFQUERYPARAM is for parameters, not for building the SQL statement. What the OP is trying to do is simply not valid (in any meaningful way).
--
Adam
-
3. Re: [Sorting not working] with CFGRID + Binding
cfwild Mar 19, 2011 7:17 PM (in response to fabio.bozzo)Hi,
I've tried your version of the default cfset, but haven't had much luck in the past. I typically use something like the following in the ORDER BY section of the SQL:
<cfif ARGUMENTS.gridSortColumn NEQ "" AND ARGUMENTS.gridSortDir NEQ "">
ORDER BY #ARGUMENTS.gridSortColumn# #ARGUMENTS.gridSortDir#
<cfelse>ORDER BY artcod ASC
</cfif>Good Luck!
<cfwild>


