|
 |
asp_databases thread: Column Sorting and Graphics + Follow up
Message #1 by "Noumaan Abubakar" <Noumaan_Abubakar@m...> on Fri, 18 May 2001 14:57:11
|
|
Someone help...
I create a HTML table which displays records after executing an SQL
statement. I've written code to allow the data in the table to be
sorted by a column in ascending order. I do this by by using Query
Strings. What I want to be able to do is display a graphic (.gif) in the
column which the data is currently sorted by.
For example if a user clicks on a column in the HTML table to sort the
data by, the data in the table will be sorted in ascending order, a
graphic (say an arrow pointing down) is placed in the column.
If the user then clicks on the column again then the data is sorted in
descending order, and a graphic (say an arrow pointing upwars) is
displayed in the column.
Does anybody know how to do this, or know any sites which would explain
how to display the graphic. Obviously I think I will need to use some sort
of flag, to decide whether to sort ascending or descending and which
graphic to display.
Thankyou in advance,
Noumaan Abubakar
Message #2 by "Jason Byrnes" <byrnes@f...> on Fri, 18 May 2001 17:00:04 -0400
|
|
are you also passing the sort order through querystrings? if not, that also
need to be in the querystring. then you need to stuff both the tablename and
sortorder querystring into variables. for example:
Dim strSortCol, strSortDirection
If Request.QueryString("Sort_Col") <> "" Then
strSortCol = Request.QueryString("Sort_Col")
Else
strSortCol = "SomeColumn1"
End If
If Request.QueryString("Sort_Direction") <> "" Then
strSortDirection = Request.QueryString("Sort_Direction")
Else
strSortDirection = "DESC"
End If
Then set your SQL statement to:
strSQL = "SELECT SomeColumn1, SomeColumn2, SomeColumn3 FROM SomeTable ORDER
BY " & strSortCol & " " & strSortOrder
When you write the TH test whether your writing the Sort_Column To see if
you need a graphic, and If so, what Direction your sorting in to determin
the graphic. For ex:
Response.Write "<th>" & vbCrLf
Response.Write "<a href=""pagename.asp?Sort_Col=SomeColumn1&Sort_Direction="
'if the sort order is set to descending write a link that will revers the
sort order
If strSortDirection = "DESC" Then
Response.Write "ASC"">Column1</a>"
'If this column is the column that the database is sorted by put in a down
arrow
If strSortCol = "Column1" Then
Response.Write "<img src=""images/downarrow.gif"">"
End If
'Ok its ascending then still need a link to reverse it
Else
Response.Write "DESC"">Column1</a>"
'If this column is the column that the database is sorted by put in an up
arrow
If strSortCol = "Column1" Then
Response.Write "<img src=""images/uparrow.gif"">"
End If
End If
Response.Write "</th>" & vbCrLf
Hope that helps
Jason
"Noumaan Abubakar" <Noumaan_Abubakar@m...> wrote in message
news:66716@a..._databases...
>
> Someone help...
>
> I create a HTML table which displays records after executing an SQL
> statement. I've written code to allow the data in the table to be
> sorted by a column in ascending order. I do this by by using Query
> Strings. What I want to be able to do is display a graphic (.gif) in the
> column which the data is currently sorted by.
>
> For example if a user clicks on a column in the HTML table to sort the
> data by, the data in the table will be sorted in ascending order, a
> graphic (say an arrow pointing down) is placed in the column.
>
> If the user then clicks on the column again then the data is sorted in
> descending order, and a graphic (say an arrow pointing upwars) is
> displayed in the column.
>
> Does anybody know how to do this, or know any sites which would explain
> how to display the graphic. Obviously I think I will need to use some sort
> of flag, to decide whether to sort ascending or descending and which
> graphic to display.
>
> Thankyou in advance,
>
> Noumaan Abubakar
>
>
Message #3 by "Noumaan Abubakar" <noumaan_abubakar@m...> on Tue, 22 May 2001 09:06:52
|
|
Jason,
Thanks for the help, the code which you provided helped me out and solved
my problem.
Thanks once again appreciate the help!
Noumaan Abubakar
|
|
 |