223Chapter 15Generic HTML Element ObjectsAnother button on the (Web hosting comparison)
223Chapter 15Generic HTML Element ObjectsAnother button on the page enables you to switch between the initial piecemeal version of thedocument and the unformatted version in its entirety. To load the entire document as a singlerecord, the FieldDelimand RowDelimparameters of the second objectelement eliminate theirdefault values by replacing them with characters that don t appear in the document at all. Andbecause the external file does not have a field name in the file, the default value (column1for thelone column in this document) is the data field. Thus, in the toggleComplete()function, thedataSrcproperty is changed to the desired objectelement ID, the dataFldproperty is set tothe correct value for the data source, and the dataFormatAsproperty is changed to reflect thedifferent intention of the source content (to be rendered as HTML or as plain text). When the dis- play shows the entire document, you can hide the two radio buttons by assigning a classNamevalue to the spanelement that surrounds the buttons. The classNamevalue is the identifier ofthe class selector in the document s stylesheet. When the toggleComplete()function resetsthe classNameproperty to empty, the default properties (normal inline display style) take hold. One further example demonstrates the kind of power available to the TDC under script con- trol. Listing 15-9 displays table data from a tab-delimited file of Academy Award information. The data file has eight columns of data, and each column heading is treated as a field name: Year, Best Picture, Best Director, Best Director Film, Best Actress, Best Actress Film, BestActor, and Best Actor Film. For the design of the page, only five fields from each recordappear: Year, Film, Director, Actress, and Actor. Notice in the listing how the HTML for thetable and its content is bound to the data source object and the fields within the data. The dynamic part of this example is apparent in how you can sort and filter the data, onceloaded into the browser, without further access to the original source data. The TDC objectfeatures Sortand Filterproperties that enable you to act on the data currently loaded inthe browser. The simplest kind of sorting indicates on which field (or fields via a semicolon- delimited list of field names) the entire data set should be sorted. Leading the name of thesort field is either a plus (to indicate ascending) or minus (descending) symbol. After settingthe dataobject s Sortproperty, invoke its Reset()method to tell the object to apply thenew property. The data in the bound table is immediately redrawn to reflect any changes. Similarly, you can tell a data collection to display records that meet specific criteria. In Listing15-9, two select lists and a pair of radio buttons provide the interface to the Filterprop- erty s settings. For example, you can filter the output to display only those records in whichthe Best Picture was the same picture of the winning Best Actress s performance. Simple filterexpressions are based on field names: dataObj.Filter = Best Picture = Best Actress Film ; Listing 15-9: Sorting Bound Data