on 08-05-2010 12:15 PM
Hi everybody,
I have a WD Tree based on a recursive node in the context.
On the treeNoteType is have implemented the event "onLoadChildren".
DATA lo_el_tree_merkmal TYPE REF TO if_wd_context_element.
CALL METHOD wdevent->get_context_element
EXPORTING
name = 'CONTEXT_ELEMENT'
receiving
value = lo_el_tree_merkmal
.
This shows me the node I have opened in the UI.
How can I get the childs of this node?
Thanks to all answers.
Dirk
Hi Dirk,
you have a reference to the node selected,
so if you have already created the subnode, then
data: lo_subnode type ref to if_wd_context_node.
lo_subnode = lo_el_tree_merkmal->get_child_node( wdctx_subnode ).
then to get the list of elements:
data: lt_elements type WDR_CONTEXT_ELEMENT_SET,
lo_subnode_element type ref to if_wd_context_element.
lt_elements = lo_subnode->get_elements( ).
and then you could loop at it and do whatever you needed.
loop at lt_elements into lo_subnode_element.
*blah
endloop.
If you need to create the new elements, I think that others have provided this code,
Good luck!
Chris
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Chris,
perfect. This was the solution. 10 points to you!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
In the OnLoadChildren action, use the below code.
* create the child nodes
create_node(
EXPORTING
cur_element = context_element
parent_key = parent_key ).
where parent_key is the parameter that you are gonna pass.
You can decide on whether to display the child as a node or as an item. ( which means if there will be any child node under that or if that will be the last item )
If the node doesn't have any child under it, use the below code.
DATA: lr_cur_element TYPE REF TO if_wd_context_element.
lr_cur_element = node->create_element( ).
lr_cur_element->set_attribute( name = 'NAME' value = value1 ).
lr_cur_element->set_attribute( name = 'NAME2' value = value2 ).
node->bind_element( new_item = lr_cur_element set_initial_elements
= abap_false ).
else
DATA: lr_cur_element TYPE REF TO if_wd_context_element.
lr_cur_element = cur_node->create_element( ).
lr_cur_element->set_attribute( name = 'NAME' value = value1 ).
lr_cur_element->set_attribute( name = 'NAME1' value = value2 ).
cur_node->bind_element( new_item = lr_cur_element
set_initial_elements = abap_false ).
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello Dirk,
you could use "if_wd_context_node" interface and use the method "get_child_node" or "get_child_nodes".
you need to pass the reference of the root node to the variable(type red) of type "if_wd_context_node".
Thanks and Regards
Anurag Chopra
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
78 | |
10 | |
9 | |
7 | |
6 | |
6 | |
5 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.