If you are using SQL server to limit the results, then you can not use the
@SORT option, but must use the ORDER BY SQL clause. Ted's option of using
@SORT and <@ROWS start=/stop=> only works if you initially retrieve the
entire dataset from SQL and store it as a user variable as he explained.
This will usually work, but can be deadly if you are working with many
thousands of rows or more. Robert

 

  _____  

From: WebDude [mailto:webd...@cipromo.com] 
Sent: Tuesday, March 02, 2010 12:42 PM
To: witango-talk@witango.com
Subject: RE: Witango-Talk: Multiple Sorts

 

Now for the $10,000 question... If you are using a max of 100 returns and
paging through the returns, is there a way of carrying the sort(s) through
to the next page. 

 

John Muldoon

Corporate Incentives

3416 Nicollet Ave S

Minneapolis, MN 55408-4552

612.822.2222

webd...@cipromo.com



 <http://cipromo.com/> http://cipromo.com

 

 

 

  _____  

From: WebDude [mailto:webd...@cipromo.com] 
Sent: Tuesday, March 02, 2010 11:13 AM
To: witango-talk@witango.com
Subject: RE: Witango-Talk: Multiple Sorts

Not very pretty, but this works great! Thanks!

<@IF EXPR="<@ARG sort>= 1">
        <@COMMENT>company</@COMMENT>
        <@IFEMPTY VALUE="<@VAR vsortorder>">
                <@ASSIGN NAME="vsortorder" VALUE="1 NUM ASC" SCOPE="user">
        <@else>
                <@ASSIGN NAME="vsortorder" VALUE="1 NUM ASC, <@VAR
vsortorder SCOPE=User> " SCOPE="user">
                <@ASSIGN vsortorder '<@REPLACE STR="<@VAR vsortorder>"
FINDSTR=", 1 NUM ASC" REPLACESTR="">'>
        </@IF>
<@ELSEIF EXPR="<@ARG sort>= 2">
        <@COMMENT>lname</@COMMENT>
        <@IFEMPTY VALUE="<@VAR vsortorder>">
                <@ASSIGN NAME="vsortorder" VALUE="2 NUM ASC" SCOPE="user">
        <@else>
                <@ASSIGN NAME="vsortorder" VALUE="2 NUM ASC, <@VAR
vsortorder SCOPE=User> " SCOPE="user">
                <@ASSIGN vsortorder '<@REPLACE STR="<@VAR vsortorder>"
FINDSTR=", 2 NUM ASC" REPLACESTR="">'>
        </@IF>
<@ELSEIF EXPR="<@ARG sort>= 3">
        <@COMMENT>state</@COMMENT>
                <@IFEMPTY VALUE="<@VAR vsortorder>">
                <@ASSIGN NAME="vsortorder" VALUE="3 NUM ASC" SCOPE="user">
        <@else>
                <@ASSIGN NAME="vsortorder" VALUE="3 NUM ASC, <@VAR
vsortorder SCOPE=User> " SCOPE="user">
                <@ASSIGN vsortorder '<@REPLACE STR="<@VAR vsortorder>"
FINDSTR=", 3 NUM ASC" REPLACESTR="">'>
        </@IF>
<@ELSEIF EXPR="<@ARG sort>= 4">
        <@COMMENT>customerid</@COMMENT>
        <@IFEMPTY VALUE="<@VAR vsortorder>">
                <@ASSIGN NAME="vsortorder" VALUE="4 NUM ASC" SCOPE="user">
        <@else>
                <@ASSIGN NAME="vsortorder" VALUE="4 NUM ASC, <@VAR
vsortorder SCOPE=User> " SCOPE="user">
                <@ASSIGN vsortorder '<@REPLACE STR="<@VAR vsortorder>"
FINDSTR=", 4 NUM ASC" REPLACESTR="">'>
        </@IF>
<@ELSE>
        <@COMMENT>default</@COMMENT>
        <@ASSIGN NAME="vsortorder" VALUE="" SCOPE="user">

/@IF

<@IFEMPTY VALUE="<@VAR ResultSet>">
<@else>
                <@IFEMPTY VALUE="<@VAR vsortorder>">
                <@else>
                        <@SORT ARRAY="ResultSet" scope="local" COLS="<@VAR
vsortorder SCOPE=User>">
        </@IF>
</@IF>

-----Original Message-----
From: Ted Wolfley [mailto:t...@ogdengroup.com]
Sent: Tuesday, March 02, 2010 9:48 AM
To: witango-talk@witango.com
Subject: RE: Witango-Talk: Multiple Sorts

My mistake on the @@request$vsortorder should have been @@user$vsortorder.

You will have to add a replace tag before assigning the new sort. Ex( sort
version): if existing sort order is "1,2,3,4" and the new sort to be added
is "3" to make the sort "3,1,2,4" you have to remove the existing "3" first.

Ted

-----Original Message-----
From: WebDude [mailto:webd...@cipromo.com]
Sent: Tuesday, March 02, 2010 10:25 AM
To: witango-talk@witango.com
Subject: RE: Witango-Talk: Multiple Sorts


Okay, I got the vsortorder to load... Pretty slick. First off, I cannot use
@@request$vsortorder... It just isn't being recognized. I think I have an
older version of Witango that doesn't let me use that scope. When I change
it to <@VAR vsortorder> it works fine.

Now that being said... I get to around 5 clicks (in which the sorts all work
exactly as planned) and then Witango crashes. I am muxing the result array
somehow. I am not sure how to post the sort arguments... Do I need to do a
search for every post of the sort? Here is what I have so far.

By the way... Thank you for the help... I appreciate it.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN"> <HTML> <HEAD>
        <TITLE>Matching Records</TITLE>
</HEAD>

<BODY>
<@IF EXPR="<@ARG sort>= 1">
        <@COMMENT>company</@COMMENT>
        <@IFEMPTY VALUE="<@VAR vsortorder>">
                <@ASSIGN NAME="vsortorder" VALUE="1 NUM ASC"
SCOPE="user">
        <@else>
                <@ASSIGN NAME="vsortorder" VALUE="1 NUM ASC, <@VAR
vsortorder SCOPE=User> " SCOPE="user">
        </@IF>
<@ELSEIF EXPR="<@ARG sort>= 2">
        <@COMMENT>lname</@COMMENT>
        <@IFEMPTY VALUE="<@VAR vsortorder>">
                <@ASSIGN NAME="vsortorder" VALUE="2 NUM ASC"
SCOPE="user">
        <@else>
                <@ASSIGN NAME="vsortorder" VALUE="2 NUM ASC, <@VAR
vsortorder SCOPE=User> " SCOPE="user">
        </@IF>
<@ELSEIF EXPR="<@ARG sort>= 3">
        <@COMMENT>state</@COMMENT>
                <@IFEMPTY VALUE="<@VAR vsortorder>">
                <@ASSIGN NAME="vsortorder" VALUE="3 NUM ASC"
SCOPE="user">
        <@else>
                <@ASSIGN NAME="vsortorder" VALUE="3 NUM ASC, <@VAR
vsortorder SCOPE=User> " SCOPE="user">
        </@IF>
<@ELSEIF EXPR="<@ARG sort>= 4">
        <@COMMENT>customerid</@COMMENT>
        <@IFEMPTY VALUE="<@VAR vsortorder>">
                <@ASSIGN NAME="vsortorder" VALUE="4 NUM ASC"
SCOPE="user">
        <@else>
                <@ASSIGN NAME="vsortorder" VALUE="4 NUM ASC, <@VAR
vsortorder SCOPE=User> " SCOPE="user">
        </@IF>
<@ELSE>
        <@COMMENT>default</@COMMENT>
        <@ASSIGN NAME="vsortorder" VALUE="" SCOPE="user">

</@IF>

<@VAR vsortorder><@COMMENT>Just so I can watch it</@COMMENT>

<@IFEMPTY VALUE="<@VAR ResultSet>">
<@else>
                <@IFEMPTY VALUE="<@VAR vsortorder>">
                <@else>
                        <@SORT ARRAY="ResultSet" scope="local"
COLS="<@VAR vsortorder SCOPE=User>">
        </@IF>
</@IF>

<P>
</P>
<TABLE BORDER=0>
<TR VALIGN=TOP ALIGN=LEFT>
        <TD>
                <B><a
href="<@APPFILE>?_function=list&sort=1">Company</a></B>
        </TD>
        <TD>
                <B><a
href="<@APPFILE>?_function=list&sort=2">Lname</a></B>
        </TD>
        <TD>
                <B><a
href="<@APPFILE>?_function=list&sort=3">State</a></B>
        </TD>
        <TD>
                <B><a href="<@APPFILE>?_function=list&sort=4">ID</a></B>
        </TD>
</TR>
<@ROWS>
<TR VALIGN=TOP>
        <TD>
                <A
HREF="<@APPFILE>?_function=detail&login_request_uid1=<@COLUMN
"login_request.ID" ENCODING=URL>&<@UserReferenceArgument>"><@COLUMN
"login_request.Company"></A>
        </TD>
        <TD>
                <@COLUMN "login_request.Lname">
        </TD>
        <TD>
                <@COLUMN "login_request.State">
        </TD>
        <TD>
                <@COLUMN "login_request.ID">
        </TD>
</TR>
</@ROWS>
</TABLE>

<P>
</BODY>
</HTML>

-----Original Message-----
From: Ted Wolfley [mailto:t...@ogdengroup.com]
Sent: Tuesday, March 02, 2010 7:35 AM
To: witango-talk@witango.com
Subject: RE: Witango-Talk: Multiple Sorts

One correction, delete the <@ASSIGN NAME="vsortorder" VALUE=""
SCOPE="user"> line before the first if statement or the sortorder will only
sort on one column.

-----Original Message-----
From: Ted Wolfley [mailto:t...@ogdengroup.com]
Sent: Tuesday, March 02, 2010 8:32 AM
To: witango-talk@witango.com
Subject: RE: Witango-Talk: Multiple Sorts

Here is a quick example, all in a Results Action:

order of columns returned: company, lname, state, customerid

build the sort:
ASSIGN NAME="vsortorder" VALUE="" SCOPE="user"> <@IF EXPR="<@ARG sort>= 1">
        <@COMMENT>company</@COMMENT>
        <@IFEMPTY VALUE="@@request$vsortorder">
                <@ASSIGN NAME="vsortorder" VALUE="1 NUM ASC"
SCOPE="user">
        <@else>
                <@ASSIGN NAME="vsortorder" VALUE="1 NUM ASC, <@VAR
vsortorder SCOPE=User> " SCOPE="user">
        </@IF>
<@ELSEIF EXPR="<@ARG sort>= 2">
        <@COMMENT>lname</@COMMENT>
        <@IFEMPTY VALUE="@@request$vsortorder">
                <@ASSIGN NAME="vsortorder" VALUE="2 NUM ASC"
SCOPE="user">
        <@else>
                <@ASSIGN NAME="vsortorder" VALUE="2 NUM ASC, <@VAR
vsortorder SCOPE=User> " SCOPE="user">
        </@IF>
<@ELSEIF EXPR="<@ARG sort>= 3">
        <@COMMENT>state</@COMMENT>
                <@IFEMPTY VALUE="@@request$vsortorder">
                <@ASSIGN NAME="vsortorder" VALUE="3 NUM ASC"
SCOPE="user">
        <@else>
                <@ASSIGN NAME="vsortorder" VALUE="3 NUM ASC, <@VAR
vsortorder SCOPE=User> " SCOPE="user">
        </@IF>
<@ELSEIF EXPR="<@ARG sort>= 4">
        <@COMMENT>customerid</@COMMENT>
        <@IFEMPTY VALUE="@@request$vsortorder">
                <@ASSIGN NAME="vsortorder" VALUE="4 NUM ASC"
SCOPE="user">
        <@else>
                <@ASSIGN NAME="vsortorder" VALUE="4 NUM ASC, <@VAR
vsortorder SCOPE=User> " SCOPE="user">
        </@IF>
<@ELSE>
        <@COMMENT>default</@COMMENT>
        <@ASSIGN NAME="vsortorder" VALUE="" SCOPE="user">

</@IF>


Sort the results set, checking if there is results first or it will
error:
<@IFEMPTY VALUE="@@request$ResultSet">
<@else>
                <@IFEMPTY VALUE="@@request$vsortorder">
                <@else>
                        <@SORT ARRAY="ResultSet" scope="request"
COLS="<@VAR vsortorder SCOPE=User>">
        </@IF>
</@IF>

I did the example in ascending order, it can also be done in descending or
both directions, just add additional <@elseif> to the sortorder statements.

Ted
-----Original Message-----
From: WebDude [mailto:webd...@cipromo.com]
Sent: Tuesday, March 02, 2010 7:31 AM
To: witango-talk@witango.com
Subject: RE: Witango-Talk: Multiple Sorts

Well... That's the way I do it. But it seems that you cannot have a blank
variable or multiple sorts within 1 variable... Or am I missing something
here.

Do you have an example?



-----Original Message-----
From: Ted Wolfley [mailto:t...@ogdengroup.com]
Sent: Monday, March 01, 2010 10:13 PM
To: witango-talk@witango.com
Subject: RE: Witango-Talk: Multiple Sorts


I found it better and faster to do the sort after the results are returned
in the Results Action.  Use a user variable and keep appending  to the
beginning, then use the variable in the sort tag.  Remember to have a way to
clear the sort and the variable

Ted


-----Original Message-----
From: WebDude [mailto:webd...@cipromo.com]
Sent: Mon 3/1/2010 7:29 PM
To: witango-talk@witango.com
Subject: Witango-Talk: Multiple Sorts

Typically in the past, I load a sort into a variable and then add that
variable as a sort in the search function...

I then use an argument to change the sorts...

<@IFEQUAL <@ARG sort> "1"><@ASSIGN sort "company_info.company">/@IF
<@IFEQUAL <@ARG sort> "2"><@ASSIGN sort "company_info.lname">/@IF <@IFEQUAL
<@ARG sort> "3"><@ASSIGN sort "company_info.state">/@IF <@IFEQUAL <@ARG
sort> "4"><@ASSIGN sort "company_info.customer_id">/@IF

I've been going around and around on this... is there anyway to hold onto
the sorts so, let's say, they click on Company first, and then click on last
name, they get a sort by lname, company. An thus, if they click next on
State, they get a sort of state, lname, company... and so on.

I'm sure this has comeup before... I just can't find the answer.

Thanks!



________________________________________________________________________
TO UNSUBSCRIBE: Go to http://www.witango.com/developer/maillist.taf

________________________________________________________________________
TO UNSUBSCRIBE: Go to http://www.witango.com/developer/maillist.taf
________________________________________________________________________
TO UNSUBSCRIBE: Go to http://www.witango.com/developer/maillist.taf
________________________________________________________________________
TO UNSUBSCRIBE: Go to http://www.witango.com/developer/maillist.taf
________________________________________________________________________
TO UNSUBSCRIBE: Go to http://www.witango.com/developer/maillist.taf
________________________________________________________________________
TO UNSUBSCRIBE: Go to http://www.witango.com/developer/maillist.taf
________________________________________________________________________
TO UNSUBSCRIBE: Go to http://www.witango.com/developer/maillist.taf

________________________________________________________________________
TO UNSUBSCRIBE: Go to http://www.witango.com/developer/maillist.taf


________________________________________________________________________

TO UNSUBSCRIBE: Go to http://www.witango.com/developer/maillist.taf

________________________________________________________________________
TO UNSUBSCRIBE: Go to http://www.witango.com/developer/maillist.taf

<<image001.gif>>

Reply via email to