Data Binding in Docentric Toolkit is a mechanism for associating tagging elements with data. For example, the Field element is a placeholder element used for rendering single values on a document. For this purpose the Field element exposes the property 'Value' which itself represents a data binding point. It holds all necessary information for the Field element to obtain and render the value form the provided data sources at report generation time.

Most elements have at least one data binding property but some have more than one. The List element has similarly to the Field element the property 'Value' which points to the collection of items the List element will render on the document. But the List element also uses data bindings for setting up the sorting of these collection of items.
Every time you want to select a particular data for an element the binding mechanism is used in the form of a data binding property (e.g. Value).

The data binding in Docentric Toolkit has two parts: the binding source and the binding path. The binding source can be set to one of the following:

  • One of the Data Sources defined on the report template.
  • The Current Data Context if exists in a given context.

On the other side, the binding path is used to select a member of the data/object represented by the selected binding source. For example, if you want to use the Field element to write the customer's name, you would set the 'Value' binding source to the data source representing the Customer object and the 'Value' binding path to the Name (Name is one of the properties of the .NET type Customer).

Binding a Field element to the property FirstName of type Customer

Binding Control

Most tagging elements have at least one binding property. For example, the Field element has a binding property property Value which means that this property's value always holds a data binding information (pointing to a specific piece of data). All binding properties are represented by the Binding Control. This is a vital part of the user interface in the Docentric Toolkit Add-In for MS Word. It is used to define a binding for the specific binding property of a tagging element. The Binding Control visually follows the concept of data-binding described above. Everytime you use the Binding Control to define a data binding you must set the Binding Source and optionaly the Binding Path.

Binding Control

To edit the binding you need to click the Binding Control which pops up the the small box where you can select the binding source and path.

Binding Control in a case of binding to a '.NET Object' data source

(Current) Data Context

When setting binding source you can always choose among the data sources defined on the template. But sometimes this is not enough. Consider the following example. We want to write a list of customers on the document. For this purpose we added the collection of Customer objects as the data source to the report template. To render the collection items we can use the List element and set its 'Value' binding source to the Customer collection data source. Since the List element only acts as a repater and doesn't tell which Customer's information we would like to display we should also insert couple of Field elements inside the List element in order to diplay the customer first name, last name, and so on. When inserting a Field element intside the List element we can now also choose the Current Data Context for the 'Value' binding source. The Current Data Context in this case represents one particular Customer object and it is provided by the parent List element. The List element is one of the elements that set/provide the data context for their nested elements.

.Net Object Binding

When the schema is available for a data source you are binding against you can always select the correct binding path by simply clicking on the right node in the scema tree inside the Binding Control. But in case schema is not available you will have to write binding paths manually. When binding to the binding source representing a .NET object the binding path is described by using the following syntax:

[Member1].[Member2]. ...[Membern]

Example:
Binding Source = Customer        Binding Path = Address.Country

Binding a Field element to a .NET value
Note that only public Properties and Fields are allowed to be accessed and used in the binding paths. You cannot bind to private members.

XML Binding

When binding to the binding source representing an XML element the binding path is described by using XPath. You can use all standard features of the XPath including predicates and built-in functions. Since you can harness all the power of the XPath language you are able to do the most complex data shaping for any data binding property of a tagging element. You can use the schema tree in the Binding Control to select (create) simple XPath expressions while the more complex ones you will have to write manually.

Binding to an XML data source - This is an example of a more complex XPath expression that was written by hand.

DTS Object Binding

The new DTS type system was introduced to improve the template design user experience for non-technical, business users. The DTS type system is much more simple compared to a .NET data type system. It only provides a small set of basic types which are easy to comprehend by a non-technical user but comprehensive enough to be used to describe any hierarchical data structure.

The data type system consists of the following types:

  • TextText
  • NumberNumber
  • DateTimeDateTime
  • BooleanBoolean
  • DTS BinaryBinary
  • ComplexComplex
  • ListList

When the schema is available for a data source you are binding against you can always select the correct binding path by simply clicking on the right node in the scema tree inside the Binding Control. But in case schema is not available you will have to write binding paths manually. When binding to the binding source representing a DTS value/object the binding path is described by using the following syntax:

[Field1].[Field2]. ...[Fieldn]

Example:
Binding Source = Customer        Binding Path = Address.Country

Binding to a DTS data source