| |   Skin:   
      User: Not logged in 
Newsletter Signup
XSLT Library
Latest XML Blogs
Featured Examples
Featured Articles
Book Chapters
Training Courses
Sign In
My Profile
My Articles
My Examples
My Favorites
My Resources
Add a Resource
About Me
My Blog
HeadGeek Articles
Talking Portfolio
World Trip Pics

Sorting Data Islands by clicking on the column header (using behaviors).
Author: David Silverlight
Published: 11/25/2005 4:09 PM
Category: Debugging, XML, XSL
Summary: This snippet demonstrates how to use behaviors to Sort a table by clicking on the column header. It also uses behaviors to highlight the row when moving the mouse over it.

This snippet demonstrates adding the following two functionalities to an Databound HTML table:

a) Allowing the user to sort the table in ascending/descending order when the column header is clicked.
b) Highlighting the current row when the user mouses over it as well as highlighting the selected row when the user clicks on it.

One very sexy aspect of this implementation is that it makes use of behaviors. Using behaviors, the snippet demonstrates how to add this functionality without having to add alot of javascript/vbscript code each time around. Simply add the behavior to your table and the functionality comes along with it. Since I have to add this type of functionality to just about every single HTML table that I create in a web application, this saves tons of time.

Additional Notes: Well, the full sourcecode is downloadable. However, the cliffnotes are shown below. The sourcecode is documented as well and will explain it all.

a) To add the ability to highlight the current row and "sort by clicking on the column header" you will need to simply add the behavior to the table as follows: <table style="Behavior: url("....> b) To indication which xml attribute in the xml document is sorted when you click on the column header, just add the "SortField" attribute to the html table column. Examples are as follows:

<td SortField="FirstName".....
<td SortField="LastName".....
<td SortField="ResidenceType".....
<td SortField="ResidenceType"....
<td SortField="State">State.....

Yes, this assumes that the xml document is attribute normalized, but it is not a very big leap to modify to handle xml documents that are element normalized.


Fans of "The Office"
Dwight Bobbleheads are here!
  “It's me! I'm the bobblehead! Yes!”

Advertise on XMLPitstop

Advertise on XMLPitstop

EggHead Cafe
Web Servicee development
Buy text ads here!
server online backup
Color Laser Printer
Diesel sunglasses
Skype vs. sipcall
VoIP Internettelefonie
Buy text ads here!

Interested in Text ads?
2,223 Total Members
36 members(last 30 days)
8 members(last 7 days)
2 members(today)

1,609 Total Discussions
12 Posts(last 30 days)
0 Posts(last 7 days)
0 Posts(today)

17,260 Total Blog Posts
1,839 Blogs(last 30 days)
342 Blogs(last 7 days)
49 Blogs(today)

8,699 Newsgroup Posts
0 Posts(last 30 days)
0 Posts(last 7 days)
0 Posts(today)

13,786 Total Resources
5 Resources(last 30 days)
1 Resources(last 7 days)
0 Resources(today)


David Silverlight's| 2801 Florida Ave #225|Miami, FL 33133|Ph:305-447-1139