"appendItems"

The attributes "appendItems" allows to add new items to a tree widget.

Synopsis

shape.appendItems(string parentId, dyn_string ids, dyn_string|dyn_dyn_string texts [,string after]);

Parameters

Parameters Description
shape Name of the object
parentId ID of the parent element
ID IDs of the items
text

The texts for the new items.

  • dyn_string: each element corresponds to the text for the respective first column
  • dyn_dyn_string: each dyn_string element contains the list of texts for several columns (Number of texts should match the number of IDs. If dynlen(texts) < dynlen(IDs), empty strings are used for the remaining columns).
afterId Item after which the new item is added. If an empty string "" is defined, the new item is inserted at the start (which is the same behavior as "insertItem"). If afterId is not defined, the item is added at the end.

Description

The attribute "appendItems" allows to add new items to a tree widget. It is not possible to check for already existing IDs since there is no "NC" option for this attribute.

Example

The following example adds first three columns and then two different elements to a tree.

main()
{    
  //Add three columns
  TREE1.addColumn("SURNAME");
  TREE1.addColumn("FIRST NAME");
  TREE1.addColumn("ADDRESS");
  //Append the "WHOLE NAME" item
  TREE1.appendItemNC("","WHOLE NAME","WHOLE_NAME");
  //Append three sub items 
  dyn_string names = makeDynString("Mueller","Schmidt", "Kaufmann"), ids = makeDynString("MUELLER","SCHMIDT", "KAUFMANN");
  this.appendItems("WHOLE NAME", ids, names);
  //Set the texts in the "FIRST NAME" column
  TREE1.setText("MUELLER", 1, "Maria");
  TREE1.setText("SCHMIDT", 1, "Anna");
  TREE1.setText("KAUFMANN", 1, "Jan");
  //Set the texts in the "ADDRESS" column
  TREE1.setText("MUELLER", 2, "Hauptstr. 1");
  TREE1.setText("SCHMIDT", 2, "Wienerstr. 10");
  TREE1.setText("KAUFMANN", 2, "Nebenstr. 100");
  //Append three subitems below the "MUELLER" item
  TREE1.appendItemNC("MUELLER", "CHILDREN_M0", "CHILDREN");
  TREE1.appendItemNC("MUELLER", "CHILDREN_M1", "");
  TREE1.appendItemNC("MUELLER", "CHILDREN_M2", "");
  //Set the texts in the "FIRST NAME" column for the CHILDREN items
  TREE1.setText("CHILDREN_M1", 1, "Klaus");
  TREE1.setText("CHILDREN_M2", 1, "Anika");
 }   

Open the tree widget:

Assignment

Tree widget