4D v14.3

SET LIST ITEM

Home

 
4D v14.3
SET LIST ITEM

SET LIST ITEM 


 

SET LIST ITEM ( {* ;} list ; itemRef | * ; newItemText ; newItemRef {; sublist ; expanded} ) 
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 last item appended to the list, or * for the current item in the list
newItemText  String in New item text
newItemRef  Longint in New item reference number
sublist  ListRef in New sublist attached to item, or 0 for no sublist (detaching current one, if any), or -1 for no change
expanded  Boolean in Indicates if the optional sublist will be expanded or collapsed

The SET LIST ITEM command modifies the item designated by the itemRef parameter within the list whose reference number or object name is passed 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.

You can pass a reference number in itemRef. If there is no item with the item reference number you passed, the command does nothing. You can optionally pass 0 in itemRef to designate the last item added to the list using APPEND TO LIST.

Lastly, you can pass * in itemRef: in this case, the command will apply to the current item of the list. If several items are selected manually, the current item is the one that was selected last. If no item is selected, the command does nothing.

If you work with item reference numbers, build a list in which the items have unique reference numbers, otherwise you will not be able to distinguish the items. For more information, refer to the Managing Hierarchical Lists section.

You pass the new text for the item in newItemText. To change the item reference number, pass the new value in newItemRef; otherwise, pass the same value as itemRef.

To attach a list to the item, pass the list reference number in subList. In this case, you also specify if the newly sublist is expanded by passing TRUE in expanded; otherwise, pass FALSE.

To detach a sublist already attached to the item, pass 0 (zero) in sublist. In this case, it is a good idea to have previously obtained the reference number of that list using APPEND TO LIST, so you can later delete the sublist using CLEAR LIST, if you no longer need it.

If you do not want to change the sublist property of the item, pass -1 in sublist.

Note: Even if they are optional, both the sublist and expanded parameters must be passed jointly.

hList is a list whose items have unique reference numbers. The following object method for a button adds a child item to the current selected list item.

 $vlItemPos:=Selected list items(hList)
 If($vlItemPos>0)
    GET LIST ITEM(hList;$vlItemPos;$vlItemRef;$vsItemText;$hSublist;$vbExpanded)
    $vbNewSubList:=Not(Is a list($hSublist))
    If($vbNewSubList)
       $hSublist:=New list
    End if
    vlUniqueRef:=vlUniqueRef+1
    APPEND TO LIST($hSubList;"New Item";vlUniqueRef)
    If($vbNewSubList)
       SET LIST ITEM(hList;$vlItemRef;$vsItemText;$vlItemRef;$hSublist;True)
    End if
    SELECT LIST ITEMS BY REFERENCE(hList;vlUniqueRef)
 End if

See example for the command GET LIST ITEM.

See example for the command APPEND TO LIST.

 
PROPERTIES 

Product: 4D
Theme: Hierarchical Lists
Number: 385

 
HISTORY 

Modified: 4D v11 SQL

 
SEE ALSO 

GET LIST ITEM
GET LIST ITEM PROPERTIES
SET LIST ITEM PROPERTIES

 
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)