Look at the highlighted sections of the HTML below to see the OBJECT tag for the tabular data control (TDC) on the page, where the HTML table is associated with it using the DATASRC attribute, and where data is associated with cells of the table using the DATAFLD attribute.
The sample also dynamically changes the background color of table headers when you pass the mouse over them. And when you click one of the headers, the rows of the table will be resorted by setting properties of the TDC, and calling its Reset method. The event handlers (i.e., ONMOUSEOVER, ONMOUSEOUT, ONCLICK) where this happens are highlighted.
<HTML> <HEAD> <TITLE>Tabular Data Control Sample</TITLE> <SCRIPT LANGUAGE=JAVASCRIPT> function titleSort() { musiclist.SortAscending = true; musiclist.SortColumn = "Title"; musiclist.Reset(); } function artistSort() { musiclist.SortAscending = true; musiclist.SortColumn = "Artist"; musiclist.Reset(); } </SCRIPT> </HEAD> <OBJECT ID=musiclist CLASSID="clsid:333C7BC4-460F-11D0-BC04-0080C7055A83"> <PARAM NAME="DataURL" VALUE="musiclist0623.txt"> <PARAM NAME="UseHeader" VALUE="True"> </OBJECT> Click on one of the column headers to sort rows by that column (in ascending order). <P> <TABLE BORDER=1 BORDERCOLOR=WHITE DATASRC=#musiclist> <THEAD> <TR BGCOLOR="#F5F5DC"> <TH LANGUAGE=JAVASCRIPT ONMOUSEOVER="this.bgColor='#FFFFFF'" ONMOUSEOUT="this.bgColor='#F5F5DC'" ONCLICK="titleSort();"> <FONT FACE=Verdana,Arial SIZE=2 COLOR="#2F4F4F">Music Title</FONT></TH> <TH LANGUAGE=JAVASCRIPT ONMOUSEOVER="this.bgColor='#FFFFFF'" ONMOUSEOUT="this.bgColor='#F5F5DC'" ONCLICK="artistSort();"> <FONT FACE=Verdana,Arial SIZE=2 COLOR="#2F4F4F">Artist</FONT></TH> </TR> </THEAD> <TBODY> <TR BGCOLOR="#FFFACD"> <TD><FONT FACE=Verdana,Arial SIZE=2 COLOR="#2F4F4F"><DIV DATAFLD="Title"></FONT></TD> <TD><FONT FACE=Verdana,Arial SIZE=2 COLOR="#2F4F4F"><DIV DATAFLD="Artist"></FONT></TD> </TR> </TBODY> </TABLE> </BODY> </HTML>
Below are the contents of MUSICLIST0623.TXT. It is the text file on the server that is the music database. The tabular data control in the sample has its DataURL property set to download the data from this file. The first line of the file includes the names for the columns that scripts use. The table elements refer to these column names using the DATAFLD attribute. In order to get the tabular data control to treat the first line of the file as column names (i.e. Title and Artist), its UseHeader property is set to true.
Title,Artist "Gasoline",Swamp Mama Johnson "Couldn't Stand the Weather",Stevie Ray Vaughan "Fumbling toward Ecstasy",Sarah McLaughlin "So Long, So Wrong",Alison Kraus and Union Station "Indigo Girls",Indigo Girls "Beatles: Live at the BBC",Beatles "From the Cradle",Eric Clapton "School House Rocks Rocks",Various Artists "Walking on a Wire",Lowen and Navarro "A Love Supreme",John Coltrane Quartet "Softly As I Leave You",Frank Sinatra "I Remember Tommy",Frank Sinatra "Jimmy Dorsey - Greatest Hits",Jimmy Dorsey "Time Signatures: A Career Retrospective",Dave Brubeck "Peter Nero & Friends - It Had to Be You",Various Artists "The Verve Story 1944-1994",Various Artists "Benny Goodman Volume 6: Rainbow Grill '66 and '67",Benny Goodman "The Best of Art Blakey and the Jazz Messengers",Art Blakey "Artie Shaw and His Orchestra 1949",Artie Shaw "Great Moments in Jazz",Various Artists "Swing That Music",Various Artists "A Man and His Music",Frank Sinatra "The Glenn Miller Collection",Glenn Miller "It Might As Well be Swing",Various Artists "Ray Charles - Genius + Soul = Jazz",Ray Charles "Dion and the Belmonts - Their Best",Dion "The Best of the Monkees",The Monkees "Mario Lanza - The Legendary Tenor",Mario Lanza "Gershwin Greatest Hits",Gershwin "Peter Nero Plays the Music of Duke Ellington",Peter Nero "The Will to Swing",Oscar Peterson "The Popular Recordings",Glenn Miller "Ella Fitzgerald and Louis Armstrong: Ella and Louis",Ella Fitzgerald/Louis Armstrong "Ella Fitzgerald and Louis Armstrong: Ella and Louis Again",Ella Fitzgerald/Louis Armstrong "The Oscar Peterson Trio: We Get Requests",Oscar Peterson "Oscar Peterson and the Trumpet Kings",Oscar Peterson "The Complete Young Oscar Peterson",Oscar Peterson "Frank Sinatra: September of My Years",Frank Sinatra "The Frank Sinatra Collection",Frank Sinatra "The Oscar Peterson Trio: A Jazz Portrait of Frank Sinatra",Oscar Peterson "Verve Jazz Masters",Stephane Grappelli "Queen Ida's Greatest Hits",Queen Ida "Slide of Hand",Roy Rogers "Gish",Smashing Pumpkins "Best Blues and Originals",Rory Block
© 1999 Microsoft Corporation. All rights reserved. Terms of use.