IDynamicInstance.Add

Syntax

Add(Attrs: Array; Parent: Integer; Direction: DimDirection): Integer;

Parameters

Attrs. Array of new element attributes.

Parent. Index of parent element.

Direction. New element layout variant.

Description

The Add method adds a new element to dictionary.

Example

Executing the example requires a form containing the DimensionTree component with the DimensionTree1 identifier, the UiDimension component with the UiDimension1 identifier and the Button component with the Button1 identifier. Determine the UiDimension1 component as data source for the DimensionTree1 component. Data source for the UiDimension1 component must be MDM table dictionary with set dynamic loading of elements.

The example is a handler of the OnClick event for the Button1 component.

Sub Button1OnClick(Sender: Object; Args: IMouseEventArgs);
Var
    Dim: IDynamicInstance;
    Arr: Array[2Of Variant;
    Element: Integer;
Begin
    Dim := UiDimension1.DimInstance As IDynamicInstance;
    Element := DimensionTree1.FocusedElement;
    // Determine key of new element
    Arr[0] := 100;
    // Determine name of new element
    Arr[1] := "New element";
    // Add new element
    Dim.Add(Arr, Element, DimDirection.FirstChild);
End Sub Button1OnClick;

On clicking the Button1 button new element will be created and added to the dictionary. Element selected by user will be a parent element for new element.

See also:

IDynamicInstance