Tree Control Drop? Event in LV 8
Hi,
I developed one application using LV 7.1 which uses tree control Drop? event.
using this event I can get and compare source tag and target tag and based on result I can omite the Drag and Drop event.
But in LV 8 for Drop? event I am not getting Source and Target Tags. Same function how I can implement in LV 8.0?
Hello,
There is a lengthy thread on this topic here (including comments from the owner of Drag-and-Drop on the LabVIEW team):
http://forums.ni.com/ni/board/message?board.id=170&message.id=158683
-D
Darren Nattinger, CLA
LabVIEW Artisan and Nugget Penman
Similar Messages
-
How to use the drop event of the tree control in LabVIEW 8.20?
Hi,
I am using the two tree controls in my application to provide a option for the user to drag and drop item from one tree to the other. I have to validate the user selection. I tried to capture the user drop event using the event structure. The problem I am facing is, I am not able to drop the item even though i have wired a constant true to the filter(Accepted?) in the event case. I have enable the property(Allow droping) in the right menu of the tree control also.
While configuring an event case for (drop, drag entered and some thing like this) only I am getting the problem otherwise it is working fine.
What do i need to do to caprture the drop event ?
Is there any way to avoid the item duplication while droping a new item in the tree control ?
or how can i do this?
Thanks,
Pandiarajan RHi Pandiarajan,
I hope you are doing well today! There is a lengthy discussion on the Tree Control Drag & Drop feature at this forums post including contributions from the developer of the Drag & Drop feature:
Tree Control Drag & Drop in LabVIEW 8
By avoiding item duplication, do you mean that you don't want the same item to be in the old tree control or do you not want more than one item in the new tree control?
Adnan Zafar
Certified LabVIEW Architect
Coleman Technologies -
How can I drag and drop an item from one Tree control to another in LabVIEW 7.1?
You can use the mouse up and down event on the two tree controls but the problem is making the correct selection in the second tree control. I want to be able to switch over to the selection bar of the second tree control so that I can place my item in the correct position. I know all possible workarounds with double-clicks and so on... but I really want a windows drag and drop.
This is what I have for the moment. Please check the library below. I need to activate the selection bar of the second tree control somehow to get the position in the control. The VI below is written in LV 7.1
Attachments:
Drag&Drop.llb 65 KBHi Jones,
As far as I know this feature is currently not supported by the Tree control. A workaround, would be to use the vertical position of the mouse in the button up event to determine what line you�re dropping the item.
If you would like the Tree control to include the drag and drop feature, please submit this as a Product Suggestion under the feedback at www.ni.com/contact.
Good luck!
Best regards,
Philip C.
Applications Engineer
National Instruments
www.ni.com/ask
- Philip Courtois, Thinkbot Solutions -
Re-create Tree control drag and drop move
Hello,
Ive got a tree control where dragEnabled=true and I have
custom handlers for dragEnter, dragOver, and dragDrop so that I can
drag/drop from datagrid's to the tree and it works fine.
The issue is now the built in tree functionality for moving
nodes around within the tree is gone. When I set dropEnabled=true
it breaks the ability to drop from the datagrid to the tree.
How can i keep the ability to move tree nodes within the tree
and also be able to drag and drop from a datagrid onto the tree?
Thanks for any help!While doing more testing I found the solution.. seriously...
dont know how I should have known this one...
on Tree dragOver handler:
if( from.id == 'data_grid' ) event.preventDefault(); -
Issue : drag and drop from list control to tree control
Hi,
I was trying a drag and drop from list control to tree control. I have used some sample data to populate list and tree controls .
It is working fine . except one problem ..
Prob : when i drag an item to tree control .. it gets added .. now tree contains (X+1) data in list .. say X is the inital number of nodes in a tree node.
now if i drag another item from list to last item in the tree node .. i.e at X+1 index. .. it throws null pointer exception.
I am considerably new in flex programming . looking for help from experts ..
Below is my code :
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
layout="horizontal"
creationComplete="init()">
<mx:Script>
<![CDATA[
import mx.controls.listClasses.IListItemRenderer;
import mx.rpc.events.FaultEvent;
import mx.rpc.events.ResultEvent;
import mx.utils.ObjectUtil;
import mx.collections.ICollectionView;
import mx.core.UIComponent;
import mx.managers.DragManager;
import mx.events.DragEvent;
import mx.controls.Alert;
import mx.controls.Label;
import mx.events.CloseEvent;
private var homePath:String="/home/e311394/dndTest/";
private var destPath:String="/home/e311394/dndDest/";
private var eid:String="e311394";
private var actn:String;
[Bindable]
private var cm:ContextMenu;
private var cmi:ContextMenuItem;
[Bindable]
private var dp:ArrayCollection;
private function init():void
cmi=new ContextMenuItem("Remove");
cmi.enabled=true;
cmi.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT, contextMenuItem_menuItemSelect);
cm=new ContextMenu();
cm.hideBuiltInItems();
cm.customItems=[cmi];
cm.addEventListener(ContextMenuEvent.MENU_SELECT, contextMenuItem_menuSelect);
list.contextMenu=cm;
private function contextMenuItem_menuSelect(evt:ContextMenuEvent):void
list.selectedIndex=lastRollOverIndex;
private function contextMenuItem_menuItemSelect(evt:ContextMenuEvent):void
var loclSelectedRow:Object=list.selectedItem;
var lostrSelectedMenuItem:String;
lostrSelectedMenuItem=evt.target.caption;
if (loclSelectedRow != null)
var obj:Object=new Object()
obj.label=loclSelectedRow.label as String;
//Alert.show(obj.label);
if (lostrSelectedMenuItem == "Remove")
if(loclSelectedRow!=null)
var pth:String=homePath.concat(loclSelectedRow.label);
//Alert.show(pth);
//FlexDnDRemoteService.process(eid,"delete",pth,"-");
var coll:ArrayCollection=list.dataProvider as ArrayCollection;
if (coll.contains(loclSelectedRow))
coll.removeItemAt(coll.getItemIndex(loclSelectedRow));
public function onTreeDragEnter(event:DragEvent):void
event.preventDefault();
DragManager.acceptDragDrop(event.target as UIComponent);
tree.showDropFeedback(event);
protected function onTreeDragOver(event:DragEvent):void
event.preventDefault();
event.currentTarget.hideDropFeedback(event);
try
var index:int=tree.calculateDropIndex(event);
catch (e:Error)
DragManager.showFeedback(DragManager.NONE);
return;
tree.selectedIndex=index;
var draggedOverItem:Object=tree.selectedItem;
public function onTreeDragExit(event:DragEvent):void
event.preventDefault();
tree.hideDropFeedback(event);
private function showAlert():void
Alert.yesLabel="Move";
Alert.noLabel="Copy";
Alert.buttonWidth=70;
Alert.show("Copy / Move ?", "Confirm", Alert.YES | Alert.NO | Alert.CANCEL, this, alertListener, null, Alert.OK);
private function alertListener(eventObj:CloseEvent):void
var result:Boolean=false;
if (eventObj.detail == Alert.CANCEL)
//Alert.show("CANCEL");
return;
if (eventObj.detail == Alert.YES)
//Alert.show("YES");
result=true;
else if (eventObj.detail == Alert.NO)
//Alert.show("NO");
result=false;
var index:int=tree.calculateDropIndex(treedropevt);
//Alert.show("Drop Pos" + index.toString());
/* var treeList:ArrayCollection=tree.dataProvider as ArrayCollection;
Alert.show(" index"+index+"Length "+treeList.length);
if(index > treeList.length)
Alert.show("Returning");
return;
var items:Array=new Array();
if (treedropevt.dragSource.hasFormat("items"))
items=items.concat(treedropevt.dragSource.dataForFormat("items") as Array);
var parentItem:Object;
parentItem=getObjectTarget();
/* if (tree.dataDescriptor.isBranch(tree.indexToItemRenderer(index).data))
parentItem=tree.indexToItemRenderer(index).data;
else
var dropParentPackage:Object = tree.mx_internal::_dropData.parent as Object;
Alert.show("HAck"+dropParentPackage.toString());
parentItem=tree.getParentItem(tree.indexToItemRenderer(index).data);
//Alert.show("Lenght "+ObjectUtil.getClassInfo(parentItem).properties.length);
//Alert.show("Lenght "+ObjectUtil.getClassInfo(parentItem).properties.length);
var position:int=0;
/* if(ObjectUtil.getClassInfo(parentItem).properties.length==0)
Alert.show("Returning");
return;
if (parentItem != null)
try
while (tree.indexToItemRenderer(index).data != parentItem)
//Alert.show(tree.indexToItemRenderer(index).data.toString());
if (index > 0)
index--;
//Alert.show("Insiade");
position++;
catch (e:Error)
Alert.show("Catch" + index.toString());
return;
for each (var item:Object in items)
var obj:Object=new Object()
obj.label=item.label as String;
if (parentItem != null)
//Alert.show("ADDED");
tree.dataDescriptor.addChildAt(parentItem, obj, position++);
else
//Alert.show("PARENT NULL");
tree.dataDescriptor.addChildAt(tree.selectedItem, obj, position++);
var spth:String=homePath.concat(item.label);
//Alert.show(spth);
var dpth:String=destPath.concat(item.label);
//Alert.show(dpth);
if (result == true)
removeItems();
//FlexDnDRemoteService.process(eid,"move",spth,dpth);
else
//FlexDnDRemoteService.process(eid,"copy",spth,dpth);
tree.validateNow();
public function getObjectTarget():Object
var dropData:Object=tree.mx_internal::_dropData as Object;
if (dropData.parent != null)
return dropData.parent;
else
// if there is not parent (root of the tree), I take the root directly
var renderer:IListItemRenderer=tree.indexToItemRenderer(0);
return renderer.data;
public function removeItems():void
//remove moved elements
var items:Array=treedropevt.dragSource.dataForFormat("items") as Array;
var coll:ArrayCollection=list.dataProvider as ArrayCollection;
for each (var item:Object in items)
if (coll.contains(item))
coll.removeItemAt(coll.getItemIndex(item));
private var treedropevt:DragEvent;
public function onTreeDragDrop(event:DragEvent):void
treedropevt=event;
showAlert();
event.preventDefault();
tree.hideDropFeedback(event);
public function resultHandler(event:ResultEvent):void
Alert.show("Success", "Status");
public function faultHandler(event:FaultEvent):void
Alert.show(event.fault.faultString, "Failure");
]]>
</mx:Script>
<mx:ArrayCollection id="listDP">
<mx:Object label="File1.dnd"/>
<mx:Object label="File2.dnd"/>
<mx:Object label="File3.dnd"/>
<mx:Object label="File4.dnd"/>
<mx:Object label="File5.dnd"/>
</mx:ArrayCollection>
<mx:Number id="lastRollOverIndex"/>
<!--
<mx:ArrayCollection id="treeDP">
<mx:Object label="/home">
<mx:children>
<mx:Object label="dummy1.ks"/>
<mx:Object label="dummy2.ks"/>
<mx:Object label="e493126">
<mx:children>
<mx:ArrayCollection>
<mx:Object label="/home/e493126/sample1.ks"/>
</mx:ArrayCollection>
</mx:children>
</mx:Object>
</mx:children>
</mx:Object>
</mx:ArrayCollection>
-->
<mx:ArrayCollection id="treeDP">
<mx:Object label="/dndDest">
<mx:children>
<mx:ArrayCollection>
<mx:Object label="sample1.ks"/>
<mx:Object label="sample2.ks"/>
<mx:Object label="sample3.ks"/>
<mx:Object label="sample4.ks"/>
<mx:Object label="sample5.ks"/>
<mx:Object label="sample6.ks"/>
</mx:ArrayCollection>
</mx:children>
</mx:Object>
</mx:ArrayCollection>
<mx:List id="list"
itemRollOver="lastRollOverIndex = event.rowIndex"
width="50%"
dragEnabled="true"
dataProvider="{listDP}"
labelField="label"
allowMultipleSelection="true"
dragMoveEnabled="false">
</mx:List>
<mx:Tree id="tree"
width="50%"
dragEnabled="true"
dataProvider="{treeDP}"
dragEnter="onTreeDragEnter(event)"
dragOver="onTreeDragOver(event)"
dragExit="onTreeDragExit(event)"
dragDrop="onTreeDragDrop(event)"
labelField="label"
liveScrolling="true">
</mx:Tree>
<mx:RemoteObject id="FlexDnDRemoteService"
showBusyCursor="true"
destination="FlexDnD">
<mx:method name="process"
result="resultHandler(event)"
fault="faultHandler(event)"/>
</mx:RemoteObject>
</mx:Application>
Thanks,
RajivYa , i have searched and have used the same code.
But needed to customize few things like:
stop dnd in same tree
drop some item into a folder ..( onto it ) etc
have achieved the same .. but this issue ..
i think the tree dataprovider (contents internally is not being updated .. only the UI)
any suggestions ?
- Rajiv -
Drag and Drop between two ALV Tree Controls
Hello all,
I have designed a spilt control of two ALV Trees using CL_GUI_ALV_TREE.
I have a top node as the Sales order Number and the child node as the items belonging to that sales order number.
Now i need to drag and drop the lines from one sales order to another.
Also these drag drop can take place between the nodes of the two different trees.
Can someone provide with a detail example as i need to complete the same urgently.
Regards,
ArunOnce check the Below code For tree to tree drag an drop
* CLASS lcl_main DEFINITION
CLASS lcl_main DEFINITION.
PUBLIC SECTION.
* Types
TYPES:
BEGIN OF t_ekpo,
ebeln TYPE ebeln,
ebelp TYPE ebelp,
END OF t_ekpo.
TYPES:
BEGIN OF t_vbap,
vbeln TYPE vbeln,
posnr TYPE vbelp,
END OF t_vbap.
* Internal Tables
DATA:
i_ekpo TYPE STANDARD TABLE OF t_ekpo,
i_ekpo_op TYPE STANDARD TABLE OF t_ekpo,
i_vbap TYPE STANDARD TABLE OF t_vbap,
i_vbap_op TYPE STANDARD TABLE OF t_vbap,
i_fcat_ekpo TYPE lvc_t_fcat,
i_fcat_vbap TYPE lvc_t_fcat.
* Work Areas
DATA:
wa_ekpo TYPE t_ekpo,
wa_ekpo1 TYPE t_ekpo,
wa_vbap TYPE t_vbap,
wa_vbap1 TYPE t_vbap.
* Data Declarations
DATA:
g_ebeln TYPE ebeln,
g_vbeln TYPE vbeln_va.
DATA: g_variant TYPE disvariant,
g_hierarchy_header TYPE treev_hhdr,
g_handle_drag TYPE i,
g_handle_drop TYPE i.
* Class data
DATA:
splitter TYPE REF TO cl_gui_splitter_container,
container TYPE REF TO cl_gui_custom_container,
container_1 TYPE REF TO cl_gui_container,
container_2 TYPE REF TO cl_gui_container,
tree1 TYPE REF TO cl_gui_alv_tree,
tree2 TYPE REF TO cl_gui_alv_tree,
g_drag TYPE REF TO cl_dragdrop,
g_drop TYPE REF TO cl_dragdrop.
* Constants
CONSTANTS:
c_30(2) TYPE c VALUE '30'.
* Methods
METHODS:
get_data, " Data Fatch
build_display, " Display Container
display_ekpo, " Ekpo table display
display_vbap, " Vbap table display
add_node_ekpo " Add node to Ekpo
IMPORTING table TYPE t_ekpo
key TYPE lvc_nkey
text TYPE lvc_value
flag TYPE c
CHANGING i_key TYPE lvc_nkey,
add_node_vbap " Add node to vbap
IMPORTING table TYPE t_vbap
key TYPE lvc_nkey
text TYPE lvc_value
flag TYPE c
CHANGING i_key TYPE lvc_nkey,
dnd_behaviour, " Drag and drop behavour
register_events_ekpo, " Register Events Ekpo
register_events_vbap, " Register events vbap
handle_drag_multiple " Drag Multiple Values
FOR EVENT on_drag_multiple
OF cl_gui_alv_tree
IMPORTING sender node_key_table fieldname drag_drop_object,
handle_drop " Drop the values
FOR EVENT on_drop
OF cl_gui_alv_tree
IMPORTING sender node_key drag_drop_object,
add_node_drop " Add node to Drop Node
IMPORTING table TYPE t_ekpo
key TYPE lvc_nkey
text TYPE lvc_value
CHANGING i_key TYPE lvc_nkey.
ENDCLASS. " Lcl_main DEFINITION
* CLASS LCL_DRAGOBJ DEFINITION
* Drag And drop Structure
CLASS lcl_dragobj DEFINITION INHERITING FROM lcl_main FINAL.
PUBLIC SECTION.
* Types
TYPES: BEGIN OF t_node_info,
l_ekpo TYPE t_ekpo,
l_node_text TYPE lvc_value,
l_node_key TYPE lvc_nkey,
END OF t_node_info.
* Data
DATA: i_node_info TYPE TABLE OF t_node_info,
wa_node_info TYPE t_node_info.
ENDCLASS. " LCL_DRAGOBJ DEFINITION
* Object Declarations
DATA obj_main TYPE REF TO lcl_main.
* Initialization *
INITIALIZATION.
CREATE OBJECT obj_main.
* Selection Screen *
SELECTION-SCREEN BEGIN OF BLOCK block1 WITH FRAME.
SELECT-OPTIONS:
s_ebeln FOR obj_main->g_ebeln,
s_vbeln FOR obj_main->g_vbeln MATCHCODE OBJECT cs_vbeln.
SELECTION-SCREEN END OF BLOCK block1.
* Start of Selection *
START-OF-SELECTION.
* Call Screen
CALL SCREEN 100.
* CLASS lcl_main IMPLEMENTATION
* Local class Implementation
CLASS lcl_main IMPLEMENTATION.
* Get Data *
METHOD get_data.
* Data from Ekpo
SELECT ebeln
ebelp
FROM ekpo
UP TO 100 ROWS
INTO TABLE i_ekpo
WHERE ebeln IN s_ebeln.
* Data from Vbap
SELECT vbeln
posnr
FROM vbap
UP TO 100 ROWS
INTO TABLE i_vbap
WHERE vbeln IN s_vbeln.
ENDMETHOD. " Get_data
* Build Display *
METHOD build_display.
* Create Container
CREATE OBJECT container
EXPORTING
container_name = 'CUST_CONT'.
* Split the container
CREATE OBJECT splitter
EXPORTING
parent = container
rows = 1
columns = 2.
CALL METHOD splitter->get_container
EXPORTING
row = 1
column = 1
RECEIVING
container = container_1.
CALL METHOD splitter->get_container
EXPORTING
row = 1
column = 2
RECEIVING
container = container_2.
* create tree control
CREATE OBJECT tree1
EXPORTING
parent = container_1
node_selection_mode = cl_gui_column_tree=>node_sel_mode_multiple
item_selection = 'X'
no_html_header = 'X'
no_toolbar = 'X'
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
create_error = 3
lifetime_error = 4
illegal_node_selection_mode = 5
failed = 6
illegal_column_name = 7.
IF sy-subrc NE 0.
CLEAR sy-subrc.
ENDIF. " IF sy-subrc NE 0.
CREATE OBJECT tree2
EXPORTING
parent = container_2
node_selection_mode = cl_gui_column_tree=>node_sel_mode_multiple
item_selection = 'X'
no_html_header = 'X'
no_toolbar = 'X'
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
create_error = 3
lifetime_error = 4
illegal_node_selection_mode = 5
failed = 6
illegal_column_name = 7.
IF sy-subrc NE 0.
CLEAR sy-subrc.
ENDIF. " IF sy-subrc NE 0.
g_variant-report = sy-repid.
g_variant-handle = space.
g_variant-log_group = space.
g_variant-username = space.
g_variant-text = space.
g_variant-dependvars = space.
* Call method for get data
CALL METHOD get_data.
* Drap And Drop behaviour method
CALL METHOD dnd_behaviour.
* Display the Ekpo table
CALL METHOD obj_main->display_ekpo.
* Diaplay the vbap table
CALL METHOD obj_main->display_vbap.
CALL METHOD tree1->frontend_update.
CALL METHOD tree2->frontend_update.
ENDMETHOD. " Build_display
* Display EKPO *
METHOD display_ekpo.
* Data
DATA:
l_key1 TYPE lvc_nkey,
l_key2 TYPE lvc_nkey,
l_key3 TYPE lvc_nkey,
l_node_text TYPE lvc_value.
* ALV control service modules
CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
EXPORTING
i_buffer_active = 'X'
i_structure_name = 'EKPO'
i_client_never_display = 'X'
i_bypassing_buffer = space
CHANGING
ct_fieldcat = i_fcat_ekpo
EXCEPTIONS
inconsistent_interface = 1
program_error = 2
OTHERS = 3.
IF sy-subrc EQ 0.
DELETE i_fcat_ekpo FROM 4.
ENDIF. " IF sy-subrc EQ 0.
g_hierarchy_header-heading = 'Purchase Order Details'(001).
g_hierarchy_header-tooltip = 'Purchase Order'(002).
g_hierarchy_header-width = c_30.
g_hierarchy_header-width_pix = ' '.
* Diaply
CALL METHOD tree1->set_table_for_first_display
EXPORTING
is_hierarchy_header = g_hierarchy_header
is_variant = g_variant
CHANGING
it_outtab = obj_main->i_ekpo_op
it_fieldcatalog = i_fcat_ekpo.
LOOP AT i_ekpo INTO wa_ekpo1.
MOVE wa_ekpo1 TO wa_ekpo.
l_key1 = ''.
AT NEW ebeln.
MOVE wa_ekpo-ebeln TO l_node_text.
* Call method for Add Node to Ekpo
CALL METHOD add_node_ekpo
EXPORTING
table = wa_ekpo
key = l_key1
text = l_node_text
flag = space
CHANGING
i_key = l_key2.
ENDAT.
CLEAR l_node_text.
MOVE wa_ekpo-ebelp TO l_node_text.
* Call method for Add Node to Ekpo
CALL METHOD add_node_ekpo
EXPORTING
table = wa_ekpo
key = l_key2
text = l_node_text
flag = 'X'
CHANGING
i_key = l_key3.
ENDLOOP. " LOOP AT i_ekpo INTO wa_ekpo1.
* Call method For Register events
CALL METHOD register_events_ekpo.
ENDMETHOD. " Display_ekpo
* Display VBAP *
METHOD display_vbap.
* Data
DATA:
l_key1 TYPE lvc_nkey,
l_key2 TYPE lvc_nkey,
l_key3 TYPE lvc_nkey,
l_node_text TYPE lvc_value.
REFRESH i_fcat_vbap.
* ALV control service modules
CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
EXPORTING
i_buffer_active = 'X'
i_structure_name = 'VBAP'
i_client_never_display = 'X'
i_bypassing_buffer = space
CHANGING
ct_fieldcat = i_fcat_vbap
EXCEPTIONS
inconsistent_interface = 1
program_error = 2
OTHERS = 3.
IF sy-subrc EQ 0.
DELETE i_fcat_vbap FROM 4.
ENDIF. " IF sy-subrc EQ 0.
g_hierarchy_header-heading = 'Sales Order Details'(003).
g_hierarchy_header-tooltip = 'Sales Order'(004).
g_hierarchy_header-width = c_30.
g_hierarchy_header-width_pix = ' '.
* Display
CALL METHOD tree2->set_table_for_first_display
EXPORTING
is_hierarchy_header = g_hierarchy_header
is_variant = g_variant
CHANGING
it_outtab = obj_main->i_vbap_op
it_fieldcatalog = i_fcat_vbap.
LOOP AT i_vbap INTO wa_vbap1.
MOVE wa_vbap1 TO wa_vbap.
l_key1 = ''.
AT NEW vbeln.
MOVE wa_vbap-vbeln TO l_node_text.
* Call method for Add Node to vbap
CALL METHOD add_node_vbap
EXPORTING
table = wa_vbap
key = l_key1
text = l_node_text
flag = 'X'
CHANGING
i_key = l_key2.
ENDAT.
CLEAR l_node_text.
MOVE wa_vbap-posnr TO l_node_text.
* Call method for Add Node to vbap
CALL METHOD add_node_vbap
EXPORTING
table = wa_vbap
key = l_key2
text = l_node_text
flag = space
CHANGING
i_key = l_key3.
ENDLOOP. " LOOP AT i_vbap INTO wa_vbap1.
* Call method For Register events
CALL METHOD register_events_vbap.
ENDMETHOD. " Display_vbap
* Add Node to Ekko *
METHOD add_node_ekpo.
* Data
DATA: l_layout_node TYPE lvc_s_layn.
IF flag = 'X'.
l_layout_node-dragdropid = g_handle_drag.
ENDIF. " IF flag = 'X'.
* Add node to tree1
CALL METHOD tree1->add_node
EXPORTING
i_relat_node_key = key
i_relationship = cl_gui_column_tree=>relat_last_child
is_outtab_line = table
i_node_text = text
is_node_layout = l_layout_node
IMPORTING
e_new_node_key = i_key
EXCEPTIONS
relat_node_not_found = 1
node_not_found = 2
OTHERS = 3.
IF sy-subrc NE 0.
CLEAR sy-subrc.
ENDIF. " IF sy-subrc NE 0.
ENDMETHOD. " Add_node_ekpo
* Add Node to Vbap *
METHOD add_node_vbap.
* Data
DATA: l_layout_node TYPE lvc_s_layn.
IF flag = 'X'.
l_layout_node-dragdropid = g_handle_drop.
ENDIF. " IF flag = 'X'.
* Add node for tree2
CALL METHOD tree2->add_node
EXPORTING
i_relat_node_key = key
i_relationship = cl_gui_column_tree=>relat_last_child
is_outtab_line = table
i_node_text = text
is_node_layout = l_layout_node
IMPORTING
e_new_node_key = i_key
EXCEPTIONS
relat_node_not_found = 1
node_not_found = 2
OTHERS = 3.
IF sy-subrc NE 0.
CLEAR sy-subrc.
ENDIF. " IF sy-subrc NE 0.
ENDMETHOD. " Add_node_vbap
* Dnd behaviour *
METHOD dnd_behaviour.
* Data
DATA: effect TYPE i,
l_flavor TYPE c VALUE 'f'.
* For drag
CREATE OBJECT g_drag.
effect = cl_dragdrop=>copy.
CALL METHOD g_drag->add
EXPORTING
flavor = l_flavor
dragsrc = 'X'
droptarget = ' '
effect = effect
effect_in_ctrl = effect.
CALL METHOD g_drag->get_handle
IMPORTING
handle = g_handle_drag.
* For Drop
CREATE OBJECT g_drop.
effect = cl_dragdrop=>copy.
CALL METHOD g_drop->add
EXPORTING
flavor = l_flavor
dragsrc = ' '
droptarget = 'X'
effect = effect
effect_in_ctrl = effect.
CALL METHOD g_drop->get_handle
IMPORTING
handle = g_handle_drop.
ENDMETHOD. " Dnd_behaviour
* register events *
METHOD register_events_ekpo.
* Data
DATA: lt_events TYPE cntl_simple_events.
* Tree events registers ALV Tree
CALL METHOD tree1->get_registered_events
IMPORTING
events = lt_events.
* Register events on frontend
CALL METHOD tree1->set_registered_events
EXPORTING
events = lt_events
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
illegal_event_combination = 3.
IF sy-subrc NE 0.
CLEAR sy-subrc.
ENDIF. " IF sy-subrc NE 0.
* Event Handling
SET HANDLER obj_main->handle_drag_multiple FOR tree1.
ENDMETHOD. " Register_events_ekpo
* register events *
METHOD register_events_vbap.
* Data
DATA: lt_events TYPE cntl_simple_events.
* Tree events registers ALV Tree
CALL METHOD tree2->get_registered_events
IMPORTING
events = lt_events.
* Register events on frontend
CALL METHOD tree2->set_registered_events
EXPORTING
events = lt_events
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
illegal_event_combination = 3.
IF sy-subrc NE 0.
CLEAR sy-subrc.
ENDIF. " IF sy-subrc NE 0.
* Event
SET HANDLER obj_main->handle_drop FOR tree2.
ENDMETHOD. " Register_events_vbap
* Handle drag multiple Values *
METHOD handle_drag_multiple.
* Data
DATA: dataobj TYPE REF TO lcl_dragobj,
l_node_key TYPE lvc_nkey,
l_ekpo TYPE t_ekpo,
l_node_text TYPE lvc_value,
l_node_layout TYPE lvc_s_layn.
* Create and fill dataobject for event ON_DROP.
CREATE OBJECT dataobj.
* Loop the Node key Table
LOOP AT node_key_table INTO l_node_key.
CALL METHOD sender->get_outtab_line
EXPORTING
i_node_key = l_node_key
IMPORTING
e_outtab_line = l_ekpo
e_node_text = l_node_text
es_node_layout = l_node_layout.
IF l_node_layout-isfolder NE 'X'.
dataobj->wa_node_info-l_node_key = l_node_key.
dataobj->wa_node_info-l_ekpo = l_ekpo.
dataobj->wa_node_info-l_node_text = l_node_text.
APPEND dataobj->wa_node_info TO dataobj->i_node_info.
ENDIF. " IF l_node_layout-isfolder NE 'X'.
ENDLOOP. " LOOP AT node_key_table INTO l_node_key
drag_drop_object->object = dataobj.
ENDMETHOD. " Handle_drag_multiple
* Handle drop multiple Values *
METHOD handle_drop.
DATA: dataobj TYPE REF TO lcl_dragobj,
l_new_key TYPE lvc_nkey,
l_node_text TYPE lvc_value.
CATCH SYSTEM-EXCEPTIONS move_cast_error = 1.
* ON_DROP
dataobj ?= drag_drop_object->object.
LOOP AT dataobj->i_node_info INTO dataobj->wa_node_info.
MOVE dataobj->wa_node_info-l_node_text TO l_node_text.
* Call method for Add Node to vbap
CALL METHOD add_node_drop
EXPORTING
table = dataobj->wa_node_info-l_ekpo
key = node_key
text = l_node_text
CHANGING
i_key = l_new_key.
ENDLOOP. " LOOP AT dataobj->i_node_info INTO dataobj->wa_node_inf
* Expand the node
CALL METHOD sender->expand_node
EXPORTING
i_node_key = node_key
CALL METHOD sender->frontend_update.
ENDCATCH.
IF sy-subrc NE 0.
CALL METHOD drag_drop_object->abort.
ENDIF. " IF sy-subrc NE 0
ENDMETHOD. " Handle_drop
* Add Node to drop *
METHOD add_node_drop.
* Add node to drop tree
CALL METHOD tree2->add_node
EXPORTING
i_relat_node_key = key
i_relationship = cl_gui_column_tree=>relat_last_child
is_outtab_line = table
i_node_text = text
* is_node_layout = l_layout_node
IMPORTING
e_new_node_key = i_key
EXCEPTIONS
relat_node_not_found = 1
node_not_found = 2
OTHERS = 3.
IF sy-subrc NE 0.
CLEAR sy-subrc.
ENDIF. " IF sy-subrc NE 0
ENDMETHOD. " Add_node_drop
ENDCLASS. " lcl_main IMPLEMENTATION
*& Module STATUS_0100 OUTPUT
* Screen 100 Pbo
MODULE status_0100 OUTPUT.
SET PF-STATUS 'BACK'.
* SET TITLEBAR 'xxx'.
CALL METHOD obj_main->build_display.
ENDMODULE. " Status_0100 OUTPUT
*& Module USER_COMMAND_0100 INPUT
* Screen 100 Pai
MODULE user_command_0100 INPUT.
IF sy-ucomm EQ 'BACK'.
LEAVE TO SCREEN 0.
ENDIF. " IF sy-ucomm EQ 'BACK'
ENDMODULE. " USER_COMMAND_0100 INPUT
*& Report ZBPS_TREE_DRAG_DROP
REPORT zbps_tree_drag_drop.
* CLASS lcl_main DEFINITION
CLASS lcl_main DEFINITION.
PUBLIC SECTION.
* Types
TYPES:
BEGIN OF t_ekpo,
ebeln TYPE ebeln,
ebelp TYPE ebelp,
END OF t_ekpo.
TYPES:
BEGIN OF t_vbap,
vbeln TYPE vbeln,
posnr TYPE vbelp,
END OF t_vbap.
* Internal Tables
DATA:
i_ekpo TYPE STANDARD TABLE OF t_ekpo,
i_ekpo_op TYPE STANDARD TABLE OF t_ekpo,
i_vbap TYPE STANDARD TABLE OF t_vbap,
i_vbap_op TYPE STANDARD TABLE OF t_vbap,
i_fcat_ekpo TYPE lvc_t_fcat,
i_fcat_vbap TYPE lvc_t_fcat.
* Work Areas
DATA:
wa_ekpo TYPE t_ekpo,
wa_ekpo1 TYPE t_ekpo,
wa_vbap TYPE t_vbap,
wa_vbap1 TYPE t_vbap.
* Data Declarations
DATA:
g_ebeln TYPE ebeln,
g_vbeln TYPE vbeln_va.
DATA: g_variant TYPE disvariant,
g_hierarchy_header TYPE treev_hhdr,
g_handle_drag TYPE i,
g_handle_drop TYPE i.
* Class data
DATA:
splitter TYPE REF TO cl_gui_splitter_container,
container TYPE REF TO cl_gui_custom_container,
container_1 TYPE REF TO cl_gui_container,
container_2 TYPE REF TO cl_gui_container,
tree1 TYPE REF TO cl_gui_alv_tree,
tree2 TYPE REF TO cl_gui_alv_tree,
g_drag TYPE REF TO cl_dragdrop,
g_drop TYPE REF TO cl_dragdrop.
* Constants
CONSTANTS:
c_30(2) TYPE c VALUE '30'.
* Methods
METHODS:
get_data, " Data Fatch
build_display, " Display Container
display_ekpo, " Ekpo table display
display_vbap, " Vbap table display
add_node_ekpo " Add node to Ekpo
IMPORTING table TYPE t_ekpo
key TYPE lvc_nkey
text TYPE lvc_value
flag TYPE c
CHANGING i_key TYPE lvc_nkey,
add_node_vbap " Add node to vbap
IMPORTING table TYPE t_vbap
key TYPE lvc_nkey
text TYPE lvc_value
flag TYPE c
CHANGING i_key TYPE lvc_nkey,
dnd_behaviour, " Drag and drop behavour
register_events_ekpo, " Register Events Ekpo
register_events_vbap, " Register events vbap
handle_drag_multiple " Drag Multiple Values
FOR EVENT on_drag_multiple
OF cl_gui_alv_tree
IMPORTING sender node_key_table fieldname drag_drop_object,
handle_drop " Drop the values
FOR EVENT on_drop
OF cl_gui_alv_tree
IMPORTING sender node_key drag_drop_object,
add_node_drop " Add node to Drop Node
IMPORTING table TYPE t_ekpo
key TYPE lvc_nkey
text TYPE lvc_value
CHANGING i_key TYPE lvc_nkey.
ENDCLASS. " Lcl_main DEFINITION
* CLASS LCL_DRAGOBJ DEFINITION
* Drag And drop Structure
CLASS lcl_dragobj DEFINITION INHERITING FROM lcl_main FINAL.
PUBLIC SECTION.
* Types
TYPES: BEGIN OF t_node_info,
l_ekpo TYPE t_ekpo,
l_node_text TYPE lvc_value,
l_node_key TYPE lvc_nkey,
END OF t_node_info.
* Data
DATA: i_node_info TYPE TABLE OF t_node_info,
wa_node_info TYPE t_node_info.
ENDCLASS. " LCL_DRAGOBJ DEFINITION
* Object Declarations
DATA obj_main TYPE REF TO lcl_main.
* Initialization *
INITIALIZATION.
CREATE OBJECT obj_main.
* Selection Screen *
SELECTION-SCREEN BEGIN OF BLOCK block1 WITH FRAME.
SELECT-OPTIONS:
s_ebeln FOR obj_main->g_ebeln,
s_vbeln FOR obj_main->g_vbeln MATCHCODE OBJECT cs_vbeln.
SELECTION-SCREEN END OF BLOCK block1.
* Start of Selection *
START-OF-SELECTION.
* Call Screen
CALL SCREEN 100.
* CLASS lcl_main IMPLEMENTATION
* Local class Implementation
CLASS lcl_main IMPLEMENTATION.
* Get Data *
METHOD get_data.
* Data from Ekpo
SELECT ebeln
ebelp
FROM ekpo
UP TO 100 ROWS
INTO TABLE i_ekpo
WHERE ebeln IN s_ebeln.
* Data from Vbap
SELECT vbeln
posnr
FROM vbap
UP TO 100 ROWS
INTO TABLE i_vbap
WHERE vbeln IN s_vbeln.
ENDMETHOD. " Get_data
* Build Display *
METHOD build_display.
* Create Container
CREATE OBJECT container
EXPORTING
container_name = 'CUST_CONT'.
* Split the container
CREATE OBJECT splitter
EXPORTING
parent = container
rows = 1
columns = 2.
CALL METHOD splitter->get_container
EXPORTING
row = 1
column = 1
RECEIVING
container = container_1.
CALL METHOD splitter->get_container
EXPORTING
row = 1
column = 2
RECEIVING
container = container_2.
* create tree control
CREATE OBJECT tree1
EXPORTING
parent = container_1
node_selection_mode = cl_gui_column_tree=>node_sel_mode_multiple
item_selection = 'X'
no_html_header = 'X'
no_toolbar = 'X'
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
create_error = 3
lifetime_error = 4
illegal_node_selection_mode = 5
failed = 6
illegal_column_name = 7.
IF sy-subrc NE 0.
CLEAR sy-subrc.
ENDIF. " IF sy-subrc NE 0.
CREATE OBJECT tree2
EXPORTING
parent = container_2
node_selection_mode = cl_gui_column_tree=>node_sel_mode_multiple
item_selection = 'X'
no_html_header = 'X'
no_toolbar = 'X'
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
create_error = 3
lifetime_error = 4
illegal_node_selection_mode = 5
failed = 6
illegal_column_name = 7.
IF sy-subrc NE 0.
CLEAR sy-subrc.
ENDIF. " IF sy-subrc NE 0.
g_variant-report = sy-repid.
g_variant-handle = space.
g_variant-log_group = space.
g_variant-username = space.
g_variant-text = space.
g_variant-dependvars = space.
* Call method for get data
CALL METHOD get_data.
* Drap And Drop behaviour method
CALL METHOD dnd_behaviour.
* Display the Ekpo table
CALL METHOD obj_main->display_ekpo.
* Diaplay the vbap table
CALL METHOD obj_main->display_vbap.
CALL METHOD tree1->frontend_update.
CALL METHOD tree2->frontend_update.
ENDMETHOD. " Build_display
* Display EKPO *
METHOD display_ekpo.
* Data
DATA:
l_key1 TYPE lvc_nkey,
l_key2 TYPE lvc_nkey,
l_key3 TYPE lvc_nkey,
l_node_text TYPE lvc_value.
* ALV control service modules
CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
EXPORTING
i_buffer_active = 'X'
i_structure_name = 'EKPO'
i_client_never_display = 'X'
i_bypassing_buffer = space
CHANGING
ct_fieldcat = i_fcat_ekpo
EXCEPTIONS
inconsistent_interface = 1
program_error = 2
OTHERS = 3.
IF sy-subrc EQ 0.
DELETE i_fcat_ekpo FROM 4.
ENDIF. " IF sy-subrc EQ 0.
g_hierarchy_header-heading = 'Purchase Order Details'(001).
g_hierarchy_header-tooltip = 'Purchase Order'(002).
g_hierarchy_header-width = c_30.
g_hierarchy_header-width_pix = ' '.
* Diaply
CALL METHOD tree1->set_table_for_first_display
EXPORTING
is_hierarchy_header = g_hierarchy_header
is_variant = g_variant
CHANGING
it_outtab = obj_main->i_ekpo_op
it_fieldcatalog = i_fcat_ekpo.
LOOP AT i_ekpo INTO wa_ekpo1.
MOVE wa_ekpo1 TO wa_ekpo.
l_key1 = ''.
AT NEW ebeln.
MOVE wa_ekpo-ebeln TO l_node_text.
* Call method for Add Node to Ekpo
CALL METHOD add_node_ekpo
EXPORTING
table = wa_ekpo
key = l_key1
text = l_node_text
flag = space
CHANGING
i_key = l_key2.
ENDAT.
CLEAR l_node_text.
MOVE wa_ekpo-ebelp TO l_node_text.
* Call method for Add Node to Ekpo
CALL METHOD add_node_ekpo
EXPORTING
table = wa_ekpo
key = l_key2
text = l_node_text
flag = 'X'
CHANGING
i_key = l_key3.
ENDLOOP. " LOOP AT i_ekpo INTO wa_ekpo1.
* Call method For Register events
CALL METHOD register_events_ekpo.
ENDMETHOD. " Display_ekpo
* Display VBAP *
METHOD display_vbap.
* Data
DATA:
l_key1 TYPE lvc_nkey,
l_key2 TYPE lvc_nkey,
l_key3 TYPE lvc_nkey,
l_node_text TYPE lvc_value.
REFRESH i_fcat_vbap.
* ALV control service modules
CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
EXPORTING
i_buffer_active = 'X'
i_structure_name = 'VBAP'
i_client_never_display = 'X'
i_bypassing_buffer = space
CHANGING
ct_fieldcat = i_fcat_vbap
EXCEPTIONS
inconsistent_interface = 1
program_error = 2
OTHERS = 3.
IF sy-subrc EQ 0.
DELETE i_fcat_vbap FROM 4.
ENDIF. " IF sy-subrc EQ 0.
g_hierarchy_header-heading = 'Sales Order Details'(003).
g_hierarchy_header-tooltip = 'Sales Order'(004).
g_hierarchy_header-width = c_30.
g_hierarchy_header-width_pix = ' '.
* Display
CALL METHOD tree2->set_table_for_first_display
EXPORTING
is_hierarchy_header = g_hierarchy_header
is_variant = g_variant
CHANGING
it_outtab = obj_main->i_vbap_op
it_fieldcatalog = i_fcat_vbap.
LOOP AT i_vbap INTO wa_vbap1.
MOVE wa_vbap1 TO wa_vbap.
l_key1 = ''.
AT NEW vbeln.
MOVE wa_vbap-vbeln TO l_node_text.
* Call method for Add Node to vbap
CALL METHOD add_node_vbap
EXPORTING
table = wa_vbap
key = l_key1
text = l_node_text
flag = 'X'
CHANGING
i_key = l_key2.
ENDAT.
CLEAR l_node_text.
MOVE wa_vbap-posnr TO l_node_text.
* Call method for Add Node to vbap
CALL METHOD add_node_vbap
EXPORTING
table = wa_vbap
key = l_key2
text = l_node_text
flag = space
CHANGING
i_key = l_key3.
ENDLOOP. " LOOP AT i_vbap INTO wa_vbap1.
* Call method For Register events
CALL METHOD register_events_vbap.
ENDMETHOD. " Display_vbap
* Add Node to Ekko *
METHOD add_node_ekpo.
* Data
DATA: l_layout_node TYPE lvc_s_layn.
IF flag = 'X'.
l_layout_node-dragdropid = g_handle_drag.
ENDIF. " IF flag = 'X'.
* Add node to tree1
CALL METHOD tree1->add_node
EXPORTING
i_relat_node_key = key
i_relationship = cl_gui_column_tree=>relat_last_child
is_outtab_line = table
i_node_text = text
is_node_layout = l_layout_node
IMPORTING
e_new_node_key = i_key
EXCEPTIONS
relat_node_not_found = 1
node_not_found = 2
OTHERS = 3.
IF sy-subrc NE 0.
CLEAR sy-subrc.
ENDIF. " IF sy-subrc NE 0.
ENDMETHOD. " Add_node_ekpo
* Add Node to Vbap *
METHOD add_node_vbap.
* Data
DATA: l_layout_node TYPE lvc_s_layn.
IF flag = 'X'.
l_layout_node-dragdropid = g_handle_drop.
ENDIF. " IF flag = 'X'.
* Add node for tree2
CALL METHOD t -
Highlighted drop source from tree control?
When a user drop an item or node from one tree to another, is
there a way to detect where the user wants to drop the item/node?
Let's say a tree showing a company structure with different
departments and managers and a list of people under the managers.
Such as:
Company A
L---> R&D
..........L---> Research
..........L---> Development
.......................L---> UI
................................L---> Manager A
.............................................L--->
Personal a1
.............................................L--->
Personal a2
.............................................L--->
Personal a3
.......................L---> Algorithm
................................L---> Manager B
.............................................L--->
Personal b1
.............................................L--->
Personal b2
.............................................L--->
Personal b3
.......................L---> Architecture
................................L---> Manager C
.............................................L--->
Personal c1
.............................................L--->
Personal c2
.............................................L--->
Personal c3
A user can suffle the people under different managers bsed on
the project phases. If Personal c1 & c2 complete their tasks,
they get moved to Manager A to help out the UI. In this case, I
need to know where the c1 & c2 get move to. All personals can
only be a child of Managers. If a user accidently drop them at
category or department level, the move should be ignored. How do I
do this? Is it possible to do this within ONE tree control rather
than two? Please help! Any input is appriciated!Yes. I am able to check the dragged data. However, I cannot
grab the dropped data to compare and refuse the drop if the rule is
not allowed. If the drag and drop source are the same, it wouldn't
make since to use drag_enter event to check since it is moving a
node in the same tree. -
Drag and Drop between the Two Tree controls
Hi all,
I am Flex newbie. Can anyone please send me the drag and drop
example between the Two Tree controls.
Thank you
-Nagaraju"ndendukuri" <[email protected]> wrote in
message
news:gdnbtt$7tt$[email protected]..
> Hi all,
>
> I am Flex newbie. Can anyone please send me the drag and
drop example
> between the Two Tree controls.
>
http://flexdiary.blogspot.com/2008/07/getting-help-in-flex-builder.html -
Control Framework tree control event not trigerring
The event handle_node_double_click is not trigerring on the tree controls . I want to display the contents of the nodes on the text editor on trigerring of this event
*& Report ZCONTROLS_TREE_TEDIT_SPITTER
REPORT zcontrols_tree_tedit_spitter.
DATA : editor TYPE REF TO cl_gui_textedit,
tree TYPE REF TO cl_gui_simple_tree.
DATA : container TYPE REF TO cl_gui_custom_container,
splitter TYPE REF TO cl_gui_easy_splitter_container,
right TYPE REF TO cl_gui_container,
left TYPE REF TO cl_gui_container.
DATA : node_itab LIKE node_str OCCURS 0.
CLASS EVENT_HANDLER DEFINITION
CLASS event_handler DEFINITION.
PUBLIC SECTION.
METHODS : handle_node_double_click
FOR EVENT NODE_DOUBLE_CLICK OF cl_gui_simple_tree
IMPORTING node_key.
ENDCLASS. "EVENT_HANDLER DEFINITION
CLASS EVENT_HANDLER IMPLEMENTATION
CLASS event_handler IMPLEMENTATION.
METHOD handle_node_double_click.
perform node_double_click using node_key.
ENDMETHOD. "HANDLE_NODE_DOUBLE_CLICK
ENDCLASS. "EVENT_HANDLER IMPLEMENTATION
data : handler1 type ref to event_handler.
START-OF-SELECTION.
CALL SCREEN 9001.
*& Module start OUTPUT
text
MODULE start OUTPUT.
SET PF-STATUS 'ZSTAT1'.
IF container IS INITIAL.
CREATE OBJECT container
EXPORTING
container_name = 'CONTAINER_NAME'
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
create_error = 3
lifetime_error = 4
lifetime_dynpro_dynpro_link = 5
OTHERS = 6
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
CREATE OBJECT splitter
EXPORTING
parent = container
orientation = 1
name = 'Mohit'
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
OTHERS = 3
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
left = splitter->top_left_container.
right = splitter->bottom_right_container.
CREATE OBJECT editor
EXPORTING
parent = right
name = 'MohitEditor'
EXCEPTIONS
error_cntl_create = 1
error_cntl_init = 2
error_cntl_link = 3
error_dp_create = 4
gui_type_not_supported = 5
OTHERS = 6
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
CREATE OBJECT tree
EXPORTING
parent = left
node_selection_mode = tree->node_sel_mode_single
name = 'MohitTree'
EXCEPTIONS
lifetime_error = 1
cntl_system_error = 2
create_error = 3
failed = 4
illegal_node_selection_mode = 5
OTHERS = 6
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
PERFORM fill_tree.
CALL METHOD tree->add_nodes
EXPORTING
table_structure_name = 'NODE_STR'
node_table = node_itab
EXCEPTIONS
error_in_node_table = 1
failed = 2
dp_error = 3
table_structure_name_not_found = 4
OTHERS = 5.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
create object handler1.
set handler handler1->handle_node_double_click for tree.
ENDIF.
ENDMODULE. " start OUTPUT
*& Module USER_COMMAND_9001 INPUT
text
MODULE user_command_9001 INPUT.
CALL METHOD cl_gui_cfw=>dispatch.
ENDMODULE. " USER_COMMAND_9001 INPUT
*& Form fill_tree
text
--> p1 text
<-- p2 text
FORM fill_tree .
DATA : node LIKE node_str.
CLEAR node.
node-node_key = 'head_mohit'.
node-isfolder = 'X'.
node-text = 'Mohit'.
APPEND node TO node_itab.
CLEAR node.
node-node_key = 'Child1'.
node-relatkey = 'head_mohit'.
node-relatship = cl_gui_simple_tree=>relat_last_child.
node-text = 'Mohit is the best '.
APPEND node TO node_itab.
CLEAR node.
node-node_key = 'Child2'.
node-relatkey = 'head_mohit'.
node-relatship = cl_gui_simple_tree=>relat_last_child.
node-text = 'Mohit is the bestest '.
APPEND node TO node_itab.
CLEAR node.
node-node_key = 'head_JAIN'.
node-isfolder = 'X'.
node-text = 'jAIN'.
APPEND node TO node_itab.
CLEAR node.
node-node_key = 'Child3'.
node-relatkey = 'head_JAIN'.
node-relatship = cl_gui_simple_tree=>relat_next_sibling.
node-text = 'cnh INDIA '.
APPEND node TO node_itab.
CLEAR node.
node-node_key = 'Child4'.
node-relatkey = 'head_JAIN'.
node-relatship = cl_gui_simple_tree=>relat_last_child.
node-text = 'SAP '.
APPEND node TO node_itab.
ENDFORM. " fill_tree
*& Form node_double_click
text
-->P_NODE_KEY text
form node_double_click using p_node_key type TV_NODEKEY.
DATA : node LIKE node_str.
DATA textline(256).
DATA text_table LIKE STANDARD TABLE OF textline.
READ TABLE node_itab WITH KEY node_key = p_node_key
INTO node.
endform. " node_double_click
*& Module exit INPUT
text
module exit input.
CASE sy-ucomm.
WHEN 'EXIT'.
LEAVE PROGRAM.
ENDCASE.
endmodule. " exit INPUTHello Mohit
Here is a sample routine (taken from BCALV_TREE_02) which you have to add and adapt for your report. It does two things:
1. Register events that should be handled (required but not sufficient for event handling)
2. Set event handler for registered events
The first step is different from ALV grid controls because here all events are already registered with the control (not the control framework).
Set the event handler (statement SET HANDLER) registers the event handling with the control framework.
FORM register_events.
*§4. Event registration: tell ALV Tree which events shall be passed
* from frontend to backend.
DATA: lt_events TYPE cntl_simple_events,
l_event TYPE cntl_simple_event,
l_event_receiver TYPE REF TO lcl_tree_event_receiver.
*§4a. Frontend registration(i): get already registered tree events.
* The following four tree events registers ALV Tree in the constructor
* method itself.
* - cl_gui_column_tree=>eventid_expand_no_children
* (needed to load data to frontend when a user expands a node)
* - cl_gui_column_tree=>eventid_header_context_men_req
* (needed for header context menu)
* - cl_gui_column_tree=>eventid_header_click
* (allows selection of columns (only when item selection activated))
* - cl_gui_column_tree=>eventid_item_keypress
* (needed for F1-Help (only when item selection activated))
* Nevertheless you have to provide their IDs again if you register
* additional events with SET_REGISTERED_EVENTS (see below).
* To do so, call first method GET_REGISTERED_EVENTS (this way,
* all already registered events remain registered, even your own):
call method g_alv_tree->get_registered_events
importing events = lt_events.
* (If you do not these events will be deregistered!!!).
* You do not have to register events of the toolbar again.
*§4b. Frontend registration(ii): add additional event ids
l_event-eventid = cl_gui_column_tree=>eventid_node_double_click.
APPEND l_event TO lt_events.
*§4c. Frontend registration(iii):provide new event table to alv tree
CALL METHOD g_alv_tree->set_registered_events
EXPORTING
events = lt_events
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
illegal_event_combination = 3.
IF sy-subrc <> 0.
MESSAGE x208(00) WITH 'ERROR'. "#EC NOTEXT
ENDIF.
*§4d. Register events on backend (ABAP Objects event handling)
CREATE OBJECT l_event_receiver.
SET HANDLER l_event_receiver->handle_node_double_click FOR g_alv_tree.
ENDFORM. " register_events
Regards
Uwe -
How to handle events occuring on different items in a tree control
I am developing a small application in which I need to display different panels when user clicks on a tree control item....how to make it display a panel inside a parent panel when a user clicks an item in a tree control....any help would be greatly appreciated. thank you
If you are young work to Learn, not to earn.The tree control can handle several events that you can rely on to handle user interaction. I suggest you take a llok at treeevent.prj example that comes with CVI. In your situation, one possible event to handle is EVENT_SELECTION_CHANGE, that marks the operation the user does when clicking on a new tree item.
Proud to use LW/CVI from 3.1 on.
My contributions to the Developer Zone Community
If I have helped you, why not giving me a kudos? -
Handling event for Tree Control Collapse
Hi,
Can any one suggest how to handle an event for 'Tree Node Collapse' . I have checked with all the exised tree events.
thanks,
VenuHi Venugopal,
If you are doing tree control programmin then i can suggest you a approach for tree node collapse and expand.
for doing this follow these steps.
1. create a toolbar (use class cl_gui_toolbar), add a button and assign a FCODE to it.
2. here you register the following the event for the toolbar.
gs_event-eventid = cl_gui_toolbar=>m_id_function_selected.
3. here you set the handler for the toolbar events
SET HANDLER gref_application->handle_function_selected
FOR gref_toolbar.
4. now in your class for gref_application you write a definition and implementation.
definition
handle_function_selected FOR EVENT handle_function_selected OF cl_gui_toolbar IMPORTING fcode.
implementation
CASE fcode.
when 'collapse'.
CALL METHOD xref_tree->collapse_all_nodes.
this method might change depending upon the class you use for creating the tree.
i hope this will help you.
in case of clarification do get back to me.
regards,
Kinshuk Saxena
PS mark helpful answers -
Hi friends.........
Iam using flex tree control data coming from coldfusion file to display grid. As i click the tree folder to change the data from dynamic from grid.
How to pass the folder id from coldfusion file.. Is it possible ?.. Means give any example please....
Any One Help Me......
With Regards.,
Lingu.......When you set the dataProvider for your tree control, you actually pass an array or arraycollection or whatever to that property. The array contains objects coming from your server, right? Each object should contain a property with the folder id, something like:
var arr:Array = [{id: 1, folderID: 34, name: "..."}, {id: 2, folderID: 4, name: "..."}, ...];
Now, when you click an item in your tree or your dataGrid, you can access the folder id by:
myTree.selectedItem.folderID
Hope this helps
Dany -
Hi all,
I would like to add special handler in case of right click on the Tree control nodes.
Is there any way to do it?
Thanks in advanced,
Yaacov (Kobi) Pinhas.
Message was edited by: Yaacov PinhasYou cannot do that (yet).
Armin -
hello all,
there is one single tree component in my application.
XML is dataprovider of that tree.
e.g
<node name="Cars" id="1" isparent="true">
<node name="Audi" id="2" isparent="true">
<node name="A4" id="3" isparent="false"/>
<node name="A6" id="4" isparent="false"/>
</node>
<node name="Mercedes" id="5" isparent="true">
<node name="M-Class" id="6" isparent="false"/>
<node name="R-Class" id="7" isparent="false"/>
</node>
</node
when i drag one node and drop to another node, how can i know the xml value of
both source & destination node?
e.g
we are Dragging 'R-Class' node to 'Audi' node, on dragComplete OR dragDrop
event, how to get R-Class node id 7 & Audi node id 2 in different variables.
So we can check some validation of node and perform drag-drop operation.
Any idea?
Steve Roger.actually what i want to implement is like :
When drapDrop event complete, i want XML value of both nodes (source & target) in variables.
Then I will show dialog box having some options & instructions (e.g You wanna Move node OR Copy node to target).
Depend on user selection, do the operation.
hope u get application scenario.
is this possible for tree control using drag drop? if so, then how?
Please help.
Thank you,
Steve Roger. -
Hi Experts!
I have a small question.I have a tree control, there are many nodes in it. I have allopwed all Drag and Drop properties, and handle the following events:
- Drag Starting? to check if the selected node is "valid"
Using this event I can filter the items what I want to drag.
The tree D&Drop functionality works fine,
but I want to filter where do I want to drop the selected node. For the filtering I use Drag Over event - Coords - Point to row Column - Tag , and check the tag is valid so the drop will be in right place.
But, when I insert the Drag Over event, and Accepted - set true, the dropping not executes, nothing changes.
BTW, when I delete this Drag Over event again, the dropping executes well, but I can not filter the place where I want to Insert.
Please Help
+++ In God we believe, in Trance we Trust +++
[Hungary]See Attachment
+++ In God we believe, in Trance we Trust +++
[Hungary]
Attachments:
Test.png 23 KB
Maybe you are looking for
-
How to manage HTML DB end users in Oracle Database 10g Express Edition?
I successfully installed Oracle XE on my Windows/XP PC. I followed 'Getting Started Guide' and created a new application using the hr.employees table. I could run this application by logging in as hr/hr. How can I create other HTML DB end users to ru
-
Further info is that I have a current update of the JavaScript as of now, my Adobe software is all updated, as is my Windows 7 software. Everything was running fine until yesterday, and the only changes to my system were the Tuesday Windows updates.
-
Is it possible to interface a USB Gamepad to a RT PXI system?
We currently use a RT PXI system to control a subsea ROV. We would like to interface a Logitech Wingman Gamepad with USB interface to our RT PXI system as a Human Interface Device (HID) to control the ROV. Is it possible? The gamepad supplier has inf
-
ECC5.0 Vs ECC6.0
Dear friends, What is the major differnce between ECC 5.0 & ECC 6.0 ? (In PP implementation wise) Thanks Senthil
-
Hello, The left mouse button + Wheel for panning does not work when using programs like (Chief Architect, Google Earth, and Kindle for PC). I'm using Microsoft Bluetooth 5000 mouse, and the UltraNav also does not work even when I uninstall the extern