Class Binding

A Binding describes how to automatically set a property on a GraphObject} to a value of a property of data in the model. The target property name and the data source property name are strings. All name matching is case-sensitive.

Index

Constructor methods

Properties

Methods

Constructor methods

constructor(targetprop?: string, sourceprop?: string, conv?: (a: any, b?: any) => any): Binding

The constructor creates an empty one-way binding.

Parameters

  • targetprop?: string optional

    A string naming the target property on the target object. If this is the empty string or not supplied, the whole GraphObject is used in the call to the conversion function, which should modify the GraphObject directly.

  • sourceprop?: string optional

    A string naming the source property on the bound data object. If this is the empty string, the whole Panel.data object is used. If this argument is not supplied, the source property is assumed to be the same as the target property.

  • conv?: (a: any, b?: any) => any optional

    A function converting the data property value to the value to set the target property. If the function is null or not supplied, no conversion takes place.

Returns

Binding

Properties

public static OneWay: EnumValue

This value for Binding#mode uses data source values and sets GraphObject properties.

public static TwoWay: EnumValue

This value for Binding#mode uses data source values and GraphObject properties and keeps them in sync.

public backConverter: (a: any, b?: any) => any

Gets or sets a converter function to apply to the GraphObject property value in order to produce the value to set to a data property.

public converter: (a: any, b?: any) => any

Gets or sets a converter function to apply to the data property value in order to produce the value to set to the target property.

public mode: EnumValue

Gets or sets the directions and frequency in which the binding may be evaluated.

public sourceName: string

Gets or sets the name of the GraphObject that should act as a source object whose property should be gotten by this data binding.

public sourceProperty: string

Gets or sets the name of the property to get from the bound data object, the value of Panel#data.

public targetProperty: string

Gets or sets the name of the property to be set on the target GraphObject.

Methods

public makeTwoWay(backconv?: (a: any, b?: any) => any): Binding

Modify this Binding to set its #mode to be Binding#TwoWay, and provide an optional conversion function to convert GraphObject property values back to data values.

You should not have a TwoWay binding on a node data object's key property.

Parameters

  • backconv?: (a: any, b?: any) => any optional

Returns

Binding

public ofObject(srcname?: string): Binding

Modify this Binding to set its #sourceName property so as to identify a GraphObject in the visual tree of the bound Panel.

Parameters

  • srcname?: string optional

    the GraphObject#name of an element in the visual tree of the bound Panel; use an empty string to refer to the root panel of that visual tree.

Returns

Binding

public static parseEnum(ctor: new(...args: any[]) => Object, defval: EnumValue): (a: string) => go.EnumValue

This static method can be used to create a function that parses a string into an enumerated value, given the class that the enumeration values are defined on and a default value if the string cannot be parsed successfully.

Parameters

  • ctor: new(...args: any[]) => Object
  • defval: EnumValue

Returns

(a: string) => go.EnumValue

public static toString(val: any): string

This static method can be used to convert an object to a string, looking for commonly defined data properties, such as "text", "name", "key", or "id".

Parameters

  • val: any

Returns

string