Microsoft® Windows® 2000 Scripting Guide
« Previous | Next »
The script shown in Listing 17.7 provides a quick and easy way to display data. Like most standard Web pages, however, it does not allow you to manipulate that data in any way. The data cannot be sorted; instead, it is displayed in the order it is returned by WMI. Sorting is not the only limitation of this script; in addition, you cannot retrieve information for all the services on a computer and then choose to display only those services that are running. To filter the data display, you would need to edit and rerun the script so that it returns only the services that are running. To again look at all the services, you would need to re-edit and rerun the script.
The tabular data control (an ActiveX control that is installed with Internet Explorer) provides a way to display data in tabular format. But the tabular data control does more than just make it quick and easy to display data in a table. By adding a few lines of code, you can sort this data any way that you want; for example, you can sort a list of services by name, by status, by the service account under which they run, or by any other property in your data set. Likewise, you can also filter the data dynamically; for example, you can show all the services, dynamically hide all the services that are not running, and then dynamically show all the services again. This can all be done without having to refresh the page or requery the data set.
With the tabular data control, you do the following:
For example, a text file containing service information might look like this:
Service Name,Service Type,Service State
Alerter,Share Process,Running
AppMgmt,Share Process,Running
Ati HotKey Poller,Own Process,Stopped
<OBJECT id=
"serviceList
"CLASSID=
"clsid:333C7BC4-460F-11D0-BC04-0080C7055A83
"> <PARAM NAME=
"DataURL
"VALUE=
"c:\scripts\service_list.csv
"> <PARAM NAME=
"UseHeader
"VALUE=
"True
"> <PARAM NAME=
"TextQualifier
"VALUE=
",
"> </OBJECT>
The actual HTML code might look like this:
<TR> <TD><DIV datafld=
"Service Name
"></DIV></TD> <TD><DIV datafld=
"Service Type
"></DIV></TD> <TD><DIV datafld=
"Service State
"></DIV></TD> </TR>
After you have created the initial row, all subsequent rows in the table are created dynamically when the text file is read. Setting up one row in the table results in multiple rows (one for each line in the text file) being displayed when the Web page is opened.
You can also use other HTML formatting in creating your table. For example, if you want to display the Service Name in bold, you can insert the HTML tag for bold (<B>):
<TD><B><DIV datafld=
"Service Name
"></DIV></B></TD>
The tabular data control supports the properties shown in Table 17.5.
Table 17.5 Tabular Data Control Properties
Property | Description |
---|---|
DataURL | Specifies the location of the data file. This can be either a URL or a file path. For example, this parameter sets the DataURL to C:\Scripts\Service_List.csv:
|
FieldDelim | Identifies the field delimiter, the character used to mark the end of a field in the data file. By default, this is the comma. To set the field delimiter to another character, use the HTML value for that character. This example sets the field delimiter to the tab character:
|
TextQualifier | Specifies characters that might surround data fields in a text file. For example, in this file, the field delimiter is the comma, and the text qualifier is the quotation mark:
|
RowDelim | Identifies the character used to mark the end of each row of data. The default value is the newline character (NL), which simply means that new lines are denoted by pressing ENTER at the end of the previous line. |
UseHeader | Specifies whether the first line of the data file contains field headers. The default value is False. |
Sort | Specifies the sort order for the table. For more information, see "Sorting Data by Using the Tabular Data Control" later in this chapter. |
Filter | Provides the ability to display a subset of records based on specific criteria. For more information, see "Filtering Data by Using the Tabular Data Control" later in this chapter. |
Listing 17.11 contains a Web page that displays script output by using the tabular data control. To carry out this task, the Web page must include the following:
clsid:333C7BC4-460F-11D0-BC04-0080C7055A83.
In addition, specify the following parameters:
Listing 17.11 Displaying Data by Using the Tabular Data Control
|
|
Send us your feedback | « Previous | Next » |