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.
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(TableSortAndHighlight.htc)"....> 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:
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.