KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: Moving a Sublist and Its Attached Sublist from One Position to Another
PRODUCT: 4D | VERSION: 2003.3 | PLATFORM: Mac & Win
Published On: July 15, 2004
Your current browser may not allow you to download the asset. We recommend Mozilla Firefox or Google Chrome.
Log In

Versions: 6.8.x and 2003.x

Here is a simple method that will move a sublist within a Hierarchical List object from one position to another.

  ` Project Method: MoveSubList
  ` Description: Relocate the listitem and its attached sublist to a new position
  ` Calls: This method should be called from the object method of a Hierarchical List
  `
  `    If (Form event=On Drop )
  `      MoveSubList (Self->)
  `      REDRAW LIST(Self->)
  `    End if
  `
  ` Parameter: $1 - List Reference

C_LONGINT($1;$List)
C_LONGINT($srcObject;$srcElement;$srcProcess)
C_LONGINT($srcItemRef;$desItemRef;$sublist)
C_TEXT($srctext;$destext)
C_BOOLEAN($expand)
$List:=$1

DRAG AND DROP PROPERTIES($srcObject;$srcElement;$srcProcess)
GET LIST ITEM($List;$srcElement;$srcItemRef;$srctext;$sublist;$expand)
GET LIST ITEM($List;Drop position;$desItemRef;$destext)

DELETE LIST ITEM($List;$srcItemRef)
INSERT LIST ITEM($List;$desItemRef;$srctext;$srcItemRef;$sublist;$expand)

The method works for the dragging and dropping action by the user. Therefore, the method must be called from the On Drop event of the Object Method of the Hierarchical List object. Here is what it should look like:

If (Form event=On Drop )
    MoveSubList (Self->)
    REDRAW LIST(Self->)
End if

Here is an example of a Hierarchical List object at the initial state:

screenshot

Here is what it looks like after the SubList "BBB" is dragged and dropped on top of "JJJ":

screenshot