4D v14.3

List item parent

Home

 
4D v14.3
List item parent

List item parent 


 

List item parent ( {* ;} list ; itemRef | * ) -> Function result 
Parameter Type   Description
Operator in If specified, list is an object name (string) If omitted, list is a list reference number
list  ListRef, String in List reference number (if * omitted), or Name of list type object (if * passed)
itemRef | *  Operator, Longint in Item reference number or 0 for the last item added to the list or * for the current item in the list
Function result  Longint in Item reference number of parent item or 0 if none

The List item parent command returns the item reference number of a parent item.

Pass the reference number or object name of the list in list .

If you pass the first optional * parameter, you indicate that the list parameter is an object name (string) corresponding to a representation of the list in the form. If you do not pass this parameter, you indicate that the list parameter is a hierarchical list reference (ListRef). If you only use a single representation of the list or work with structural items (the second * is omitted), you can use either syntax. Conversely, if you use several representations of the same list and work with the current item (the second * is passed), the syntax based on the object name is required since each representation can have its own current item.

Note: If you use the @ character in the object name of the list and the form contains several lists matching this name, the List item parent command will be applied to the first object whose name corresponds.

You pass the item reference number of an item in the list or 0 or yet again *, in itemRef. If you pass 0, the command applies to the last item added to the list. If you pass *, the command applies to the current item of the list. If several items have been selected manually, the current item is the last one selected.

In return, if the corresponding item exists in the list and if this item is in a sublist (and therefore has a parent item), you obtain the item reference number of the parent item.

If there is no item with the item reference number you passed, or if you have passed * and no item is selected, or if the item has no parent, List item parent returns 0 (zero).

If you work with item reference numbers, be sure to build a list in which the items have unique reference numbers; otherwise you will not be able to distinguish the items. For more information, see the description of the APPEND TO LIST command.

Example  

Given the list named hList shown here in the Application environment:

The item reference numbers are set as follows:

ItemItem Reference Number
a100
a - 1101
a - 2102
b200
b - 1201
b - 2202
b - 3203

  • In the following code, if the item “b - 3” is selected, the variable $vlParentItemRef gets 200, the item reference number of the item “b”:
 $vlItemPos:=Selected list items(hList)
 GET LIST ITEM(hList;$vlItemPos;$vlItemRef;$vsItemText)
 $vlParentItemRef:=List item parent(hList;$vlItemRef` $vlParentItemRef gets 200
  • If the item “a - 1” is selected, the variable $vlParentItemRef gets 100, the item reference number of the item “a”.
  • If the item “a” or “b” is selected, the variable $vlParentItemRef gets 0, because these items have no parent item.

 
PROPERTIES 

Product: 4D
Theme: Hierarchical Lists
Number: 633

 
HISTORY 

Modified: 4D v11 SQL

 
SEE ALSO 

GET LIST ITEM
List item position
SELECT LIST ITEMS BY REFERENCE
SET LIST ITEM

 
ARTICLE USAGE

4D Language Reference ( 4D v12.4)
4D Language Reference ( 4D v11 SQL Release 6)
4D Language Reference ( 4D v14 R3)
4D Language Reference ( 4D v14 R2)
4D Language Reference ( 4D v13.5)
4D Language Reference ( 4D v14.3)
4D Language Reference ( 4D v14 R4)