on 11-21-2005 5:01 PM
Hi,
When I click a tree node in tree component, how do I know the level of this item?
E.g., if I click the root node, then I get the level number 1, if I click second level node, I get the number 2 etc.
Thanks!
if you need the level info when clicking the node you have to set the level values when filling the table TVIEW/TVIEW2 field TLEVEL with tree contents. Which you can read it later. the levels wont get filled/available automatically.
Regards
Raja
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
So it means I have to set the level id myself.
But my current case is that I have a table which includes 2 fields:parentid,childid. I can easily make a TVIEW table by setting the parentkey and childkey attributes. But it seems hard to calculate the level and depth of the tree.
So do you have any suggestion about this case?
Thanks a lot!
HI,
Are you transferring the XML data to be stored in some internal table?
You can select the data after reading from the table into temporary internal tables and set the level(using ID) in the layout,based on the values of the table rows.
As the data does not contain level detail,then you'l have to set the level yourself and then can read it as suggested earlier.
Regards,
Siddhartha
Hi,
when you create the tree, you don't have to specify the level. It'S sufficient to set parentid and childid correctly.
But of course, if you want to read it from the tree-table later, you have to set it before.
An alternative is to write your own method that returns the level for a given childid. Try something like this:
level = get_level( childid ).
method get_level.
* 1) get parentid for childid into lv_parent_id
* ...
* 2) call this method recursively
* IF current node is root
rv_level = 1.
* ELSE
rv_level = get_level( lv_parent_id ) + 1.
* ENDIF
endmethod.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
You can get to know the level of a tree by the ID of its node.
Like,what i did was,In the layout,
<htmlb:treeNode id = "root"
text = "MRF LIST"
isOpen = "true">
<htmlb:treeNode id = "node1"
text = "MRF's To Be Processed"
isOpen = "true"
tooltip = "MRF's to do"
toggle = "X">
<%data :tab_0 type ZDI_MRF.%>
<%loop at tab_mrf_0 into tab_0.%>
<htmlb:treeNode id = "node1<%=sy-tabix%>"
text = "<%=tab_0-MRF_NUM%>"
image = "@02@"
onNodeClick="show">
</htmlb:treeNode>
<% endloop.%>
By this,on node click in onInputProcessing,we can process it as
if event->id = 'myTree1' and event->event_type = 'click'.
data : t_event type ref to cl_htmlb_event_tree.
t_event ?= event.
temp = t_event->node.
<b> if strlen( temp ) ge '6'. </b>
data : x type string ,
tab type zdi_mrf.
<b> if temp ca 'node1%'. </b>
split temp at '1' into x node1.
endif.
By this you can get the length of the ID and hence get the level,say id strlen( temp ) = 4 ,then node = root ,if strlen( temp ) = 5 ,then level 1.
Maybe you can do something similar.
Hope this helps,
Regards,
Siddhartha
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
86 | |
10 | |
10 | |
9 | |
6 | |
6 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.