PDA

View Full Version : Using the sort in Data Assist, how do I make an icon to show the sort status?


RichGags
04-14-2009, 07:29 AM
I need to create a sortable spreadsheet. I was successful in setting up the spreadsheet with the Data Assist wizard and added sorting with a link at the top of each column. The link is the column header itself. Everything is working except I would like to show an arrow icon next to whatever column heading is sorted. (An up arrow or down arrow depending if ascending or descending).

How would I do this?

Thanks!
Rich

Ray Borduin
04-14-2009, 08:30 AM
You would have to add the images and create an IF statment by hand to show the correct arrow based on the sort value. Since this is not a directly supported feature it would require knowledge of the server language you are using and a small amount of hand code.

RichGags
04-14-2009, 09:22 AM
Ok. I think I can handle that. Can you point me in the right direction with the if statement? Or do you know where I can find a tutorial on it? I tried Googling it but I couldnt find one.

Thanks!

Ray Borduin
04-14-2009, 09:32 AM
What is your server language? Look at the code on top of the page where it is set. You will see that the sort is stored in a session variable. Your if statement would check the value of that variable.

RichGags
04-14-2009, 11:17 AM
Server language? I thought that was PHP?

Can you help me find the variable and pull in the right img depending on the sort? Ive set it up right now for simplicity with just one header sort (city). Ive attached my php page.

If the sort = city and ascending, it should show up.gif next to the column heading city.

Thanks!

Ray Borduin
04-14-2009, 12:04 PM
your if statement would be something like:

<?php
if (isset($_SESSION["WADA_OrderClause_users_Results"]) && $_SESSION["WADA_OrderClause_users_Results"] == "city") {
?>
image here
<?php
}
?>

RichGags
04-14-2009, 12:14 PM
So I would use what you wrote in the column header like this?

<th class="WADAResultsTableHeader"><a href="users_Results.php?sort=city">city:</a>
<?php
if (isset($_SESSION["WADA_OrderClause_users_Results"]) && $_SESSION["WADA_OrderClause_users_Results"] == "city") {
?>
<img src="up.gif">
<?php
}
?>
</th>

Ray Borduin
04-14-2009, 12:27 PM
That is my best guess. Writing php usually entails debugging php by hand, so if it doesn't work, write the value of the session variable to the page, maybe it has a different value than you expect.

RichGags
04-14-2009, 12:34 PM
Thanks so much. One more thing, how do I write the session variable to the page?

Ray Borduin
04-14-2009, 12:36 PM
echo();

or

print();

so something like:
<?php echo($_SESSION["WADA_OrderClause_users_Results"]); ?>


see http://www.php.net for general php information such as this. They have extensive information on php and its functionality.