Developing Web Applications with the Web ADF - Web controls  

Toc control



The table of contents, or Toc, control lists the layers on the map and shows what the features represent.  A toc is buddied with a map control.  As a result, checking a layer on in the toc control will draw it in the map control.  Each resource associated with a map control may contain one or more layers. The toc control represents each resource as a group layer, which is a layer that contains layers.

The Toc control inherits from the TreeViewPlus control, which is a Web ADF control that allows you to display data in a tree-type control with expandable nodes. TreeViewPlus is also used in the TaskResults control. It is possible to programmatically alter the nodes in the Toc by adding, moving or deleting nodes. However, keep in mind that the typical use of the Toc and Web ADF involves client callbacks rather than full page postbacks, so that server-side methods to modify the Toc cannot ordinarily be done after startup in the browser.

Assembly: ESRI.ArcGIS.ADF.Web.UI.WebControls.dll
Class: ESRI.ArcGIS.ADF.Web.UI.WebControls.Toc
Using the Toc control
  1. Add supporting controls to the page

    In order to use the control, a number of supporting controls must be available.  Set up a Web application with, at minimum, a  MapResourceManager control and a Map control using their discussion topics as a guide. Other controls may optionally be added, such as a Toolbar control for zoom/pan controls (users can also zoom/pan using mouse/keyboard combinations).
  2. Add the Toc control to the page

    Drag a Toc control onto the page. Your page should resemble the following (this layout is using a table, so your arrangement may differ):

    Page with Toc control

  3. Set the properties for the Toc control 

    In design mode, click on the Toc control to select it. The Properties window displays the properties for the control:

    Toc control properties

    The only property that you must set for the Toc control is the Map property. Click the drop-down list for its value and choose the Map control added previously.
Members

Properties


  The following table provides a list of properties of interest.  For complete reference information, see the Toc control in the library reference section.

Property Name  Type Description
BuddyControl string The Map control ID to which the Toc will be buddied to.
DisabledColor Color Color to display disabled nodes, such as nodes for layers that are not visible at the current scale.
ExpandDepth int Levels of the Toc's tree view to display on startup. For example, to display all layer names and legend swatches on startup, set ExpandDepth to 2. ExpandDepth is not automatically preserved if a full page postback occurs.
PageSize int Number of layers to display per page of the Toc. When the number of layers exceeds PageSize, links are displayed at the top of the Toc to display additional Toc pages.
RenderOnDemand bool Defers rendering of legend swatches until the layer is expanded to display the swatches. Useful when the Toc contains numerous or complex layers, or when users rarely expand the Toc to view legend swatches.
ShowLayerCheckBoxes bool Displays checkboxes for each layer, enabling the user to turn layers on and off.
ShowResourceCheckBoxes bool Displays a checkbox at the level of the resource (map service), enabling users to turn all layers in the service on or off. Useful when multiple services are added to the map.
SwatchPageSize int Maximum number of swatches to display per layer before using paging within the layer swatches. If the number of categories within the layer exceed this value, only this number are displayed at a time, and links are displayed at the top of the layer legend to display additional groups of swatches for the layer.
TocType TocType The default is SwatchList, which includes legend swatches, which represent layer symbology, in the Toc. The other option is LayerList, which displays only layer names, without legend swatches.

Discussion