Partager via


Common Node Features

Three features are common to all data view nodes:

  • Node ID

  • Node Display Name

  • Node Children

Node ID

There are two types of node IDs, depending on the context in which it is used. Node IDs that are specified for static nodes, which are nodes that do not have underlying objects, contain a different value than the node IDs specified for non-static nodes—nodes that have underlying objects.

Note that the reference to node ID corresponds to the nodeId XML attribute defined in the DataViewSupport schema.

Node ID for Static Nodes

The node ID of a static node is the portion of a non-static node's full name that represents the path leading to that non-static node. For example, the following represents the full name (the full path) of the "authors" table, which is the non-static node, and contains the static node "Tables": "/Tables/UserTables/Table[pubs.dbo.authors]".

In this case, the node ID is "/Tables/UserTables/" because it is the path that leads to the node in question.

For a description of the format of the node's full name, see FullName.

Node ID for Non-Static Nodes

However, the node ID of a non-static node represents the node that contains properties for selecting objects beneath it. This node is typically a parent node of the objects to be selected. In particular, the object selection process looks for the node ID of the next parent node in the view hierarchy that has properties for selecting objects, that is, if the first parent does not supply these properties, the node ID of the next parent up in the hierarchy is examined until a qualified parent is found.

For example, suppose a non-static table node exists in the view hierarchy called "authors" that contains two columns called "au_id" and "au_name". This table and other tables are under the "Tables" static node. To select these columns, the client needs to identify the node ID of the parent of the column selection, which in this example is the node ID of the Tables selection node. The XML below illustrates this example.

<StaticNode nodeId="Tables">
   <Children>
      <Selection type="Table">
         <SelectionNode nodeId="Table">
            <Children>
               <Selection type="Column" restrictions="{Table.Name}">
               ...
               </Selection>
            </Children>
         </SelectionNode>
      </Selection>
   </Children>
</StaticNode>

Node Display Name

Hierarchy nodes can have a display name that is displayed with their icon in the Visual Studio Server Explorer. Only static nodes, including static connection nodes, require the display name, as it can be inferred for the other node types.

To enable a node's display name, use the DisplayName element. This allows you to specify the node's name as displayed in the IDE, as well as to specify how to format the display name. (For a connection node, the appropriate element is called the InitialDisplayName element because the display name for a connection node can be modified by the user.) To format the display name, either use simple string content or reference a resource exposed by the Resources section of the XML.

You can apply a display name by using the optional when attribute, which lets you specify an expression that is evaluated to decide, conditionally, whether the given format is correct under a given set of conditions.

Conditional application of display name and format may occur for several reasons. For example, you might want to display the owner name next to the table name only under the condition that the owner name is different from the current user name.

The example code below shows representative XML for handling conditional application of the display name, as outlined in the scenario above.

<SelectionNode>
    <DisplayName when="NOT ({Schema} = {Database.UserName})">
        {Name} ({Schema})
    </DisplayName>
</SelectionNode>

However, the literal expression for this conditional expression is this: for this selection node, the display name value should be the database table name followed by the table owner in brackets, in cases where the table schema is not equal to the current user in the database.

In this example there is no default display name, but rather a name format specified by a conditional expression. This is allowed for object connection nodes and selection nodes, since these node types permit a default format to be derived from the underlying object. For static connection nodes, on the other hand, the schema enforces the requirement that at least one DisplayName element be supplied.

Node Children

Nodes must use the Children element to specify their child nodes.

There are three types of child nodes:

  • Static. Any node can have a static node for a child, including another static node. For example, an expanded "Base Tables" collection might show "System Tables" and "User Tables."

  • Selection. This child node type expands to a number of child nodes based on a selection of objects enumerated from the server. To demonstrate this, suppose in the data view you want to display a list of tables from your data source. You might write the following XML to do this:

    <StaticNode>
        <DisplayName>Tables</DisplayName>
        <Children>
            <Selection type="Table"/>
        </Children>
    </StaticNode>
    

    The XML above would cause the following hierarchy to be displayed:

    - Tables  
       - <Table 1>
       - <Table 2>
    - ...  
    

See Also

Concepts

Data View Nodes

Special Node Features