This is an extension and not part of the main GoJS library. Note that the API for this class may change at any time. If you intend to use an extension in production, you should copy the code to your own source directory. Extensions can be found in the GoJS kit under the extensions
(for loading via script tags),extensionsTS
(UMD modules), or extensionsJSM
(ES6 modules) folders. See the Extensions intro page for more information.
Constructs an Inspector and sets up properties based on the options provided. Also sets up change listeners on the Diagram so the Inspector stays up-to-date.
a string referencing the HTML ID of the to-be Inspector's div
a reference to a GoJS Diagram
an optional JS Object describing options for the inspector
Gets or sets the Diagram associated with this Inspector.
This read-only property returns the HTMLElement containing the Inspector.
Gets or sets whether the Inspector includes all properties currently on the inspected object.
The default value is true.
Gets or sets whether the Inspector automatically inspects the associated Diagram's selection. When set to false, the Inspector won't show anything until inspectObject is called.
The default value is true.
This read-only property returns the object currently being inspected.
To set the inspected object, call inspectObject.
Gets or sets whether the Inspector displays properties for multiple selected objects or just the first.
The default value is false, meaning only the first item in the Diagram.selection is inspected.
Gets or sets the properties that the Inspector will inspect, maybe setting options for those properties. The object should contain string: Object pairs represnting propertyName: propertyOptions. Can be used to include or exclude additional properties.
The default value is an empty object.
Gets or sets the function to be called when a property is modified by the Inspector. The first paremeter will be the property name, the second will be the new value, and the third will be a reference to this Inspector.
The default value is null, meaning nothing will be done.
Gets or sets how many objects will be displayed when multipleSelection is true.
The default value is 0, meaning all selected objects will be displayed for a given property.
Gets or sets whether the Inspector displays the union or intersection of properties for multiple selected objects.
The default value is false, meaning the intersection of properties is inspected.
This sets inspectedProperties[propertyName]
and creates the HTML table row for a given property:
<tr>
<td>propertyName</td>
<td><input value=propertyValue /></td>
</tr>
This method can be customized to change how an Inspector row is rendered.
the property name
the property value
the table row
This predicate should be false if the given property should not be editable by the user. Normally it only checks the value of "readOnly" on the property descriptor.
The default value is true.
the property name
the property descriptor
the data object
whether a particular property should be shown in this Inspector
This predicate should be false if the given property should not be shown. Normally it only checks the value of "show" on the property descriptor.
The default value is true.
the property name
the property descriptor
the data object
whether a particular property should be shown in this Inspector
Update the HTML state of this Inspector with the given object.
If passed an object, the Inspector will inspect that object. If passed null, this will do nothing. If no parameter is supplied, the inspectedObject will be set based on the value of inspectSelection.
an optional argument, used when inspectSelection is false to set inspectedObject and show and edit that object's properties.
This predicate function can be used as a value for the show
option for properties.
When used, the property will only be shown if present.
Useful for properties such as key
, which will be shown on Nodes and Groups, but normally not on Links
the property to check presence of
This class implements an inspector for GoJS model data objects. The constructor takes three arguments:
divid
string a string referencing the HTML ID of the to-be inspector's divdiagram
Diagram a reference to a GoJS Diagramoptions
Object an optional JS Object describing options for the inspectorOptions:
inspectSelection
boolean see inspectSelectionincludesOwnProperties
boolean see includesOwnPropertiesproperties
Object see propertiespropertyModified
function(propertyName, newValue, inspector) see propertyModifiedmultipleSelection
boolean see multipleSelectionshowUnionProperties
boolean see showUnionPropertiesshowLimit
number see showLimitOptions for properties:
show
boolean | function a boolean value to show or hide the property from the inspector, or a predicate function to show conditionally.readOnly
boolean | function whether or not the property is read-onlytype
string a string describing the data type. Supported values: "string|number|boolean|color|arrayofnumber|point|rect|size|spot|margin|select|date|datetime-local|time"defaultValue
any a default value for the property. Defaults to the empty string.choices
Array | function when type === "select", the Array of choices to use or a function that returns the Array of choices.Example usage of Inspector:
This is the basic HTML Structure that the Inspector creates within the given DIV element:
If you want to experiment with this extension, try the Data Inspector sample.