Filtering Data by Using the Tabular Data Control

Microsoft® Windows® 2000 Scripting Guide

microsoft windows 2000 scripting guide

« Previous | Next »   

Data can also be filtered by using the tabular data control. This capability can help administrators quickly spot items of interest. For example, if an administrator is interested only in services that are currently stopped, he or she can use a filter to display only those services. In this way, a single data source can serve multiple purposes. Otherwise, you might have to save information about stopped services to one text file and information about paused services to another text file.

To create a filter for the tabular data control, set the value for the Filter parameter to the name of the column to be filtered, and set the criteria for which records are to be included or excluded. For example, this line of code creates a filter that will limit data retrieval to those records for which the Service State is Stopped:

   <PARAM NAME="Filter" VALUE="Service State = Stopped"> 

Note

  • Although it is beyond the scope of this chapter to demonstrate, both filtering and sorting can be done interactively. For example, you might configure your Web page so that each time you click a column heading, the data is sorted by that column.

Scripting Steps

Listing 17.13 contains a Web page that displays script output by using the tabular data control. In this example, a filter is applied so that only services that are stopped are displayed. To carry out this task, the Web page must include the following:

  1. The starting <HTML> and <BODY> tags.
  2. An <OBJECT> tag used to insert the tabular data control. You must specify an id for the control as well as the CLASSID:

    clsid:333C7BC4-460F-11D0-BC04-0080C7055A83.

    In addition, specify the following parameters:

    • DataURL, along with the path to the comma-separated-values file.
    • UseHeader, indicating that the first row in the comma-separated-values file contains header information.
    • TextQualifier, indicating that the comma is used to separate items within each row of the text file.
    • Filter, which specifies the datafld and value to be filtered on (ServiceState = Stopped ).
  3. An <H2> tag used to provide a heading for the page.
  4. A table, with the datasrc set to #serviceList, the id assigned to the tabular data control. This means that table will derive its data from the tabular data control.
  5. A <THEAD> and <TR> tag to mark the first row in the table. Three <TD> tags are used to indicate individual columns in the table:
    • Computer
    • Service
    • Status
  6. A <TBODY> and <TROW> tag used to delineate the data columns. The three columns must specify a datafld used in the header row of the text file:
    • System Name
    • Display Name
    • Service State
  7. Ending tags for the table, body, and HTML.

Listing 17.13   Displaying Filtered Data by Using the Tabular Data Control

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 
<HTML> <BODY> <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=",">    <PARAM NAME="Filter" VALUE="Service State = Stopped"> </OBJECT> <H2>Current Service Status</H2> <table border='1' width='100%' cellspacing='0' datasrc=#serviceList> <THEAD><TR> <TD>Computer</TD> <TD>Service</TD> <TD>Status</TD> </TR> </THEAD> <TBODY> <TR> <TD><B><DIV datafld="System Name"></DIV></B></TD> <TD><DIV datafld="Display Name"></DIV></TD> <TD><DIV datafld="Service State"></DIV></TD> </TR> </TBODY> </TABLE> </BODY> </HTML>

send us your feedback Send us your feedback « Previous | Next »   


Microsoft Windows 2000 Scripting Guide(c) Automating System Administration 2003
Microsoft Windows 2000 Scripting Guide(c) Automating System Administration 2003
ISBN: N/A
EAN: N/A
Year: 2004
Pages: 635

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net