2.33 :reparent()

This method reallocates sub-nodes within tree structures. The sub-nodes are moved with their entire sub-trees. There are two different forms of the :reparent() method:

2.33.1 :reparent() (treeview)

With the :reparent() method any sub-tree can be reallocated within a treeview.

Definition

boolean :reparent
(
  integer Start  input,
  integer Count  input,
  integer Parent input,
  integer Target input
)

Parameters

integer Start input
In this parameter the index of the sub-tree to be moved is specified.
integer Count input
This parameter defines how many sub-trees are moved.
integer Parent input
In this parameter the index of the new parent node of the reallocated sub-tree is determined.
integer Target input
This parameter indicates the absolute index of the node after which the moved sub-tree is inserted.

Return value

true
The sub-tree has been moved successfully.
false
Moving the sub-tree failed.

Objects with this method

treeview

Example

dialog D

window Wn
{
  .title "Example for the :reparent() method";

  child treeview Tv
  {
    .content[1] "Company A";
    .content[2] "Miller";
    .content[3] "Mayer";
    .content[4] "Company B";
    .content[5] "Jones";
    .content[6] "Smith";
    .content[7] "Fisher";
    .style[style_lines] true;
    .style[style_buttons] true;
    .style[style_root] true;
    .level[2] 2;
    .level[3] 2;
    .level[5] 2;
    .level[6] 2;
    .level[7] 2;

    boolean Select := false;
    integer Index := 0;

    on select
    {
      if Tv.Select then
        Tv:reparent(Tv.Index, 1, Tv.activeitem, Tv.activeitem);
        Tv.Select := false;
        St.text := "";
      endif
    }
  }

  child pushbutton Pb
  {
    .text "Link company";

    on select
    {
      variable integer Index;

      Tv.Index := Tv.activeitem;
      St.text := "Select new company";
      Tv.Select := true;
    }
  }

  child statictext St
  {
    .text "";
  }
}

2.33.2 :reparent() (doccursor)

The :reparent() method reallocates the DOM node that the XML Cursor points to with all of its child nodes within an XML Document.

If the value of the .path attribute is stored elsewhere (e.g. in the .userdata attribute), it should be noted that the stored value is not adjusted when the structure of the DOM tree changes. When the :select() method is invoked with the stored value afterward, the XML Cursor may be pointing to an incorrect DOM node.

Definition

boolean :reparent
(
      object  Parent input
  { , integer Index  := -1 input }
)
boolean :reparent
(
  integer Index input
)

Parameters

object Parent input

This parameter indicates a doccursor that points to the new parent node. Indicates the new parent node.

When the Index parameter is missing, the reallocated DOM node is appended as last child of the new parent node.

integer Index input
This parameter defines the position where the moved DOM node is inserted. With the value ‑1, the reallocated DOM node is appended as last node.

Return value

The method returns true if the DOM node has been moved successfully, false otherwise.

Objects with this method

doccursor