Here's my code. It works fine. The only problem is that when I click on the columns headers, it sends a request but nothing is sorted. It set by default? I tried sortable="true" but same problem.
Ok, I have found the solution. The fact is that you have to catch the variables: sortDirection and sortValue in the script file. I add my coldfusion query code for the example, hope it helps s.o else.
<cfincludetemplate="jsonencode.cfm"> <cfqueryname="get_bookmarks_count"datasource="bookmarks">
SELECT COUNT(*) AS count FROM bookmarks </cfquery>
<cfoutput> <cfif isDefined("sortDirection") AND sortDirection IS "ascending"> <cfset sense = "ASC"> <cfelseif isDefined("sortDirection") AND sortDirection IS "descending"> <cfset sense = "DESC"> </cfif> <cfqueryname="get_bookmarks"datasource="bookmarks">
SELECT * FROM bookmarks <cfif isDefined("sortValue")>
ORDER BY #sortValue# #sense# </cfif> </cfquery> </cfoutput>
Code
9 October, 2007 - 09:12 — FrankSylvie, can you include your code (use
tags around it) and describe in more detail what the problem is ?my code
9 October, 2007 - 09:38 — sylvieHere's my code. It works fine. The only problem is that when I click on the columns headers, it sends a request but nothing is sorted. It set by default? I tried sortable="true" but same problem.
<b:dataSource name="myData" url="../index.cfm" type="array" dataRoot="mybookmarks">
<b:dataSchema>
<b:dataField name="title" key="title" />
</b:dataSchema>
</b:dataSource>
<b:listGrid dataSource="myData" readonly="true" width="100%" height="100%" rowClasses="rowClass1, rowClass2">
<b:listGridCol query="title" label="Title"/>
<b:listGridCol query="internal_url" label="Internal" />
<b:listGridCol query="external_url" label="External" />
</b:listGrid>
</b:tab>
Founded, variables catched in the script file
9 October, 2007 - 14:12 — sylvieOk, I have found the solution. The fact is that you have to catch the variables: sortDirection and sortValue in the script file. I add my coldfusion query code for the example, hope it helps s.o else.
<cfquery name="get_bookmarks_count" datasource="bookmarks">
SELECT COUNT(*) AS count FROM bookmarks
</cfquery>
<cfoutput>
<cfif isDefined("sortDirection") AND sortDirection IS "ascending">
<cfset sense = "ASC">
<cfelseif isDefined("sortDirection") AND sortDirection IS "descending">
<cfset sense = "DESC">
</cfif>
<cfquery name="get_bookmarks" datasource="bookmarks">
SELECT * FROM bookmarks
<cfif isDefined("sortValue")>
ORDER BY #sortValue# #sense#
</cfif>
</cfquery>
</cfoutput>