JohnLucania
asked on
toggle sort on a column title
This query is in place for the display:
<cfquery datasource......>
select * FROM GiftView WITH (NOLOCK)
WHERE ConstID = #myCon#
bla....
Order by Created ASC, myTable
</cfquery>
The field I have:
<TD class=notetext2 width=1% nowrap align=middle>
<B><FONT color=EEEEEE>Due Date</FONT></B>
</TD>
When I click on 'Due Date', I want to have 'toggle sort' (sort by ASC or DESC back and forth), which will be basically:
Order by Created ASC
or
Order by Created DESC
I am thinking having a fucntion something like Order by Created <cfif ......>ASC <efelse> DESC</cfif>
What would be the best way to put 'toggle sort' on 'Due Date' and how to do it?
<cfquery datasource......>
select * FROM GiftView WITH (NOLOCK)
WHERE ConstID = #myCon#
bla....
Order by Created ASC, myTable
</cfquery>
The field I have:
<TD class=notetext2 width=1% nowrap align=middle>
<B><FONT color=EEEEEE>Due Date</FONT></B>
</TD>
When I click on 'Due Date', I want to have 'toggle sort' (sort by ASC or DESC back and forth), which will be basically:
Order by Created ASC
or
Order by Created DESC
I am thinking having a fucntion something like Order by Created <cfif ......>ASC <efelse> DESC</cfif>
What would be the best way to put 'toggle sort' on 'Due Date' and how to do it?
Check out this script:
http://www.dhtmlgoodies.com/index.html?showDownload=true&whichScript=sortable_table
I have used it many times and it works great
http://www.dhtmlgoodies.com/index.html?showDownload=true&whichScript=sortable_table
I have used it many times and it works great
ASKER
The issue I am having with function goToURL(aURL) is that:
The page is having the url like this:
default.cfm?fuse_action=Ma in&Dest=Or ga&org=209 4842&showT ype=pledge installmen ts
and the query below comes before it hits the table for display.
<cfquery datasource......>
select * FROM GiftView WITH (NOLOCK)
WHERE ConstID = #myCon#
bla....
Order by Created #url.sort#, myTable
</cfquery>
It seems that the best way is to change "Order by Created" to ASC or DESC when the page is refreshed, so we will need to put a function to refresh the page.
For instance, if the page is clicked (in this case, refreshed), it becomes ASC; if clicked again, it becomes DESC, and so on. I think that is the beter way.
How do you resolve this issue?
The page is having the url like this:
default.cfm?fuse_action=Ma
and the query below comes before it hits the table for display.
<cfquery datasource......>
select * FROM GiftView WITH (NOLOCK)
WHERE ConstID = #myCon#
bla....
Order by Created #url.sort#, myTable
</cfquery>
It seems that the best way is to change "Order by Created" to ASC or DESC when the page is refreshed, so we will need to put a function to refresh the page.
For instance, if the page is clicked (in this case, refreshed), it becomes ASC; if clicked again, it becomes DESC, and so on. I think that is the beter way.
How do you resolve this issue?
ASKER
Actually, refreshing the page is not an issue for me since I know already. The question I have is how to toggle ASC or DESC on the refresh.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I have the refresh function in place. onClick="goToURL('default. cfm?fuse_a ction=Main &Dest=Orga &org=20948 42&showTyp e=pledgein stallments & .... gives more issues. As long as I figure out how to return distinctive values (i.e. 1 or 2, yes or no, on or off, etc) whenever the page is refreshed, it sould be good to go.
For instance, the first refresh gives 1, then the next refresh gives 2, the 3rd refresh gives 1, the next gives 2, etc
For instance, the first refresh gives 1, then the next refresh gives 2, the 3rd refresh gives 1, the next gives 2, etc
that's "by design"
if you wish to you can eliminate the cfif
<input type="button" name="desc" value="Sort Desc" onClick="goToURL('default. cfm?fuse_a ction=Main &Dest=Orga &org=20948 42&showTyp e=pledgein stallments &sort=Desc ');">
<input type="button" name="asc" value="Sort Asc" onClick="goToURL('default. cfm?fuse_a ction=Main &Dest=Orga &org=20948 42&showTyp e=pledgein stallments &sort=Asc' );">
this gives the user the ability to choose
if you wish to you can eliminate the cfif
<input type="button" name="desc" value="Sort Desc" onClick="goToURL('default.
<input type="button" name="asc" value="Sort Asc" onClick="goToURL('default.
this gives the user the ability to choose
my solution works fine for me..use it all the time
or
<script type="text/javascript">
function goToURL(aURL)
{
self.location = aURL;
}
<cfparam name="url.sort" default="asc">
<TD class=notetext2 width=1% nowrap align=middle>
<B><FONT color=EEEEEE>
<cfif url.sort eq "Asc">
<input type="button" name="desc" value="Sort Desc" onClick="goToURL('thispage
<cfelse>
<input type="button" name="asc" value="Sort Asc" onClick="goToURL('thispage
</cfif>
Due Date</FONT></B></TD>
<cfquery datasource......>
select * FROM GiftView WITH (NOLOCK)
WHERE ConstID = #myCon#
bla....
Order by Created #url.sort#, myTable
</cfquery>
you could also use an img
<img src="up_arrow.gif" alt="Sort Asc" onClick="goToURL('mypage.c