Forums

This topic is locked

Sort by column header in DW MX?

Posted 28 Oct 2002 18:18:23
1
has voted
28 Oct 2002 18:18:23 Brian Dunk posted:
I have a master/detail page set with names and job ID's. I would like to make each column heading a button to press that will sort the detail page set by that coumn. Is this possible in DW MX? Is there a tutorial somewhere? Any info is much appreciated.

Bdunk

Replies

Replied 29 Oct 2002 00:04:32
29 Oct 2002 00:04:32 Ned Frankly replied:
There's probably a tutorial somewhere, but the basic idea is this:

Set up your query for your recordset as:

select * from table
ORDER BY MyVar

Definition for MyVar:
MyVar DefaultSortColumnName Request.QueryString("SortBy"

Now create links on your page (the column headers) as:

MyPage.asp?SortBy=ColumnName (actual table column names)

Now, each of your column headers calls the same page, but passing a real column name as SortBy. If the page is called without the link (just 'MyPage.asp') the default definition for MyVar is used. Just be careful that each link refers to an actual column name in your table.

I usually dress this up by adding a graphical arrow of some sort beside each column name link, then conditionally display it based on the QueryString value.

Make sure that if you're using multiple page links (next, previous, page1 | page2, etc) that you include the SortBy in that link too so when people go to page 2 in your list, it's still sorted as the user requested, i.e.:

<a href="<%=nextpagelink%><%if (String(Request.QueryString("SortBy") != "undefined"{%>&SortBy=<%=Request.QueryString("SortBy"%><%}%>.

I usually preprocess this somewhere in the ASP before the body tag so the links don't look so ugly, but you get the idea.

Let me know if you need specific code: (remove my spleen to email me)

Ned Frankly

Edited by - NedFrankly on 29 Oct 2002 00:08:42

Reply to this topic