views:

968

answers:

2

I am displaying a list of items using a SAP ABAP column tree model, basically a tree of folder and files, with columns. I want to load the sub-nodes of folders dynamically, so I'm using the EXPAND_NO_CHILDREN event which is firing correctly. Unfortunately, after I add the new nodes and items to the tree, the folder is automatically collapsing again, requiring a second click to view the sub-nodes. Do I need to call a method when handling the event so that the folder stays open, or am I doing something else wrong?

* Set up event handling.
  LS_EVENT-EVENTID  = CL_ITEM_TREE_CONTROL=>EVENTID_EXPAND_NO_CHILDREN.
  LS_EVENT-APPL_EVENT = GC_X.
  APPEND LS_EVENT TO LT_EVENTS.
  CALL METHOD GO_MODEL->SET_REGISTERED_EVENTS
    EXPORTING
      EVENTS                    = LT_EVENTS
    EXCEPTIONS
      ILLEGAL_EVENT_COMBINATION = 1
      UNKNOWN_EVENT             = 2.
  SET HANDLER GO_APPLICATION->HANDLE_EXPAND_NO_CHILDREN
    FOR GO_MODEL.

...


* Add new data to tree.
  CALL METHOD GO_MODEL->ADD_NODES
    EXPORTING
      NODE_TABLE = PTI_NODES[]
    EXCEPTIONS
      ERROR_IN_NODE_TABLE = 1.

  CALL METHOD GO_MODEL->ADD_ITEMS
    EXPORTING
      ITEM_TABLE = PTI_ITEMS[]
    EXCEPTIONS
      NODE_NOT_FOUND = 1
      ERROR_IN_ITEM_TABLE = 2.
+1  A: 

It's been a while since I've played with SAP, but I always found the SAP Library to be particularly helpful when I got stuck...

I managed to come up with this one for you: http://help.sap.com/saphelp_nw04/helpdata/en/47/aa7a18c80a11d3a6f90000e83dd863/frameset.htm, specifically:

When you add new nodes to the tree model, set the flag ITEMSINCOM to 'X'.
This informs the tree model that you want to load the items for that node on demand.

Hope it helps?

Pat
A: 

Your code looks fine,

I would use the method ADD_NODES_AND_ITEMS myself if I were to add nodes and items ;)

Beyond that, try to call EXPAND_NODE after you added the items/nodes and see if that helps.

T.

tomdemuyt