Add Node to my Tree

hi all
i have a self join table with following column as select statement
SELECT 1, LEVEL, a.product, ''exit'',a.techno
FROM bom_products a
CONNECT BY PRIOR a.techno = a.set_techno
START WITH a.set_techno IS NULL
that techno is pk
and set_techno is fk
and use
following code for view my tree:
DECLARE
     htree ITEM;
     b NUMBER;
a RECORDGROUP;
BEGIN
     go_block('BLK_CHART');
htree := FIND_ITEM('BLK_CHART.T');
a := FIND_GROUP('a');
IF NOT ID_NULL(a) THEN
DELETE_GROUP(a);
END IF;
a := CREATE_GROUP_FROM_QUERY('a',
'SELECT 1, LEVEL, a.product, ''exit'',a.techno
FROM bom_products a
CONNECT BY PRIOR a.techno = a.set_techno
START WITH a.set_techno IS NULL and a.techno='''||:BLK.TECHNO||''''
b := POPULATE_GROUP(a);
FTREE.SET_TREE_PROPERTY(htree, FTREE.RECORD_GROUP, a);
END;
and no problem,
my issue is :
add child to my tree and record to my table
can any one help me to add node???????????????????

WRITE THE FOLLOWING SCRIPT IN THE WHEN-BUTTON-PRESSED
INSERT INTO TABLE VALUES (NEW_DISPLAY_LABEL,NEW_VALUE);
COMMIT;
P_PARENT_NODE_VALUE:= ftree.get_tree_node_property('tree4',:system.trigger_node,ftree.node_value);
P_PARENT_NODE := Ftree.Find_Tree_Node('tree4',P_PARENT_NODE_VALUE,Ftree.FIND_NEXT, Ftree.NODE_value, Ftree.ROOT_NODE, Ftree.ROOT_NODE);
P_NEW_NODE := ftree.add_tree_node('tree4',P_PARENT_NODE,ftree.parent_offset,ftree.last_child,ftree.expanded_node,NEW_DISPLAY_LABEL,null,NEW_VALUE);
Message was edited by:
zakaoullah

Similar Messages

  • Add node to a specific node in JTree

    I use the following TreePanel class to add node to the tree. My question is how to add a new node under
    a specific node which has been created before. In other words, how to get the path and identify the node.
    For e.g., I first loaded some raw data files and created the "raw data" node, later I need to load another file
    and create a new node under the "raw data" node. Each node is created by using user object. Any help is greatly appreicated.
    import java.awt.*;
    import javax.swing.*;
    import javax.swing.event.*;
    import javax.swing.tree.*;
    public class TreePanel extends JPanel {
      protected DefaultMutableTreeNode rootNode;
      protected DefaultTreeModel treeModel;
      protected JTree tree;
      public TreePanel() {
        super(new GridLayout(1,0));
        rootNode = new DefaultMutableTreeNode("Experiment");
        treeModel = new DefaultTreeModel(rootNode);
        tree = new JTree(treeModel);
        tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
        tree.setShowsRootHandles(true);
        JScrollPane scrollPane = new JScrollPane(tree);
        add(scrollPane);
      public JTree getTree(){
        return tree;
      /* Add child to the currently selected node. */
      public DefaultMutableTreeNode addObject(Object child){
        DefaultMutableTreeNode parentNode = null;
        TreePath parentPath = tree.getSelectionPath();
        if(parentPath == null){
          parentNode = rootNode;
        else{
          parentNode = (DefaultMutableTreeNode)(parentPath.getLastPathComponent());
        return addObject(parentNode, child, true);
      /* Add child */
      public DefaultMutableTreeNode addObject(DefaultMutableTreeNode parent, Object child){
        return addObject(parent, child, false);
      /* Add child */
      public DefaultMutableTreeNode addObject(DefaultMutableTreeNode parent, Object child, boolean shouldBeVisible){
        DefaultMutableTreeNode childNode = new DefaultMutableTreeNode(child);
        if(parent == null){parent = rootNode;}
        treeModel.insertNodeInto(childNode, parent, parent.getChildCount());
        if(shouldBeVisible){
          tree.scrollPathToVisible(new TreePath(childNode.getPath()));
        return childNode;
      /* Add child */
      public DefaultMutableTreeNode addObject(DefaultMutableTreeNode parent, DefaultMutableTreeNode child){
       if(parent == null){parent = rootNode;}
       treeModel.insertNodeInto(child, parent, parent.getChildCount());
       return child;
    }Thanks in advance!

    public static DefaultMutableTreeNode findNode(DefaultMutableTreeNode from, Object userObject) {
              if (userObject == null && from.getUserObject() == null) {
                   return from;
              } else if (userObject.equals(from.getUserObject())) {
                   return from;
              DefaultMutableTreeNode node = null;
              for (int i = 0; i < from.getChildCount(); i ++) {
                   node = (DefaultMutableTreeNode) from.getChildAt(i);
                   if (userObject == null) {
                        if (userObject == node.getUserObject()) {
                             break;
                   } else {
                        if (userObject.equals(node.getUserObject())) {
                             break;
                   node = null;
              if (node != null) {
                   return node;
              //Node not found
              //dig deeper
              for (int i = 0; i < from.getChildCount(); i ++) {
                   node = (DefaultMutableTreeNode) from.getChildAt(i);
                   if (!node.isLeaf()) {
                        node = findNode(node, userObject);
                        if (node != null) {
                             return node;
              //Not found
              return null;
         }     

  • Add node into XML Model

    Hi all,
    i would like to add datas into my xml model but i don't manage to do it.
    Here is the context :
    -I have an xml file which represents a tree
    -When the xml model is loaded, i bound it to a tree
    -Then i add nodes to my tree ( aNode.addNode(new Node ) )
    When adding a node, i would like the node to be represented to my model;
    e.g : before adding a node
    <node name="node1">
         <node name="node1_1"/>
         <node name="node1_2"/>
    </node>
    after the node is added :
    <node name="node1">
         <node name="node1_1"/>
         <node name="node1_2"/>
         <node name="new node"/>
    </node>
    I have tried  xml setProperty:
    oModel.setProperty(myPath,data);
    oModel.setProperty(myPath,data,oContext);
    Can somebody help me to achieve this?
    Thanks,
    best regards,
    Marc

    Thanks for this fast reply, i try it and i come back to you
    Edit :
    Here is my xml file :
    <?xml version="1.0" encoding="utf-8"?>
    <objectSet version="1.2.3.4">
        <aRoot code="testCode" reference="0123456789" description="TestDescription"
            owner="Tester">
            <component name="MyCompo1" type="MyCompo1Type">
                <component name="MyCompo2" type="MyCompo2Type">
                    <property name="myProperty2-1" type="string" value="null" />
                    <property name="myProperty2-2" type="string" value="null" />
                    <property name="myProperty2-3" type="string" value="null" />
                </component>
                <component name="MyCompo3" type="MyCompo3Type">
                    <property name="myProperty3-1" type="string" value="null" />
                </component>
            </component>
        </aRoot>
    </objectSet>
    I made a button with the fellowing function attached :
    aTestFunction: function(oEvent){
            console.log("Test");
            var tree = this.byId("myTree");
            var oModel = tree.getModel();
            var pty = oModel.getProperty("/aRoot/MyCompo1"); // Empty; path is not good
            var pty1 = oModel.getProperty("/aRoot/component");//something but only whitespaces when printing
            console.log(pty);//empty
            console.log(pty1);// a lot of whitespaces (9lines of different sizes)
            pty1.push("node");//Error, pty1.push is not a function
            oModel.setProperty("/aRoot/component",pty1);
    The argument of pty1.push is not good, but the function cannot be even called.
    Another try?

  • Runtime error while i add a node in ALV Tree in oops

    i am adding a node to alv tree using oop am passing a work area and when i execute it is going for a dump and it says UC_OBJECTS_NOT_CONVERTIBLE
    and the below where it is bold and italic it is where the dump is occuring
    METHOD ADD_NODE.
    FIELD-SYMBOLS: <TAB1> TYPE standard TABLE,
    <wa> type any.
    assign mt_outtab->* to <tab1>.
    insert line in outtab
    DATA: L_INDEX TYPE SY-TABIX.
    if is_outtab_line is initial.
    create initial line
    data l_dref_wa type ref to data.
    create data l_dref_wa like line of <tab1>.
    assign l_dref_wa->* to <wa>.
    l_index = 0.
    append <wa> to <Tab1>.
    else.
    APPEND IS_OUTTAB_LINE TO <TAB1>. endif.
    L_INDEX = SY-TABIX.
    add node to model
    CALL METHOD ME->ADD_MODEL_NODE
    EXPORTING
    I_RELAT_NODE_KEY = I_RELAT_NODE_KEY
    I_RELATIONSHIP = I_RELATIONSHIP
    IS_NODE_LAYOUT = IS_NODE_LAYOUT
    IT_ITEM_LAYOUT = IT_ITEM_LAYOUT
    I_NODE_TEXT = I_NODE_TEXT
    I_INDEX_OUTTAB = L_INDEX
    IMPORTING
    E_NEW_NODE_KEY = E_NEW_NODE_KEY.
    ENDMETHOD.

    HI Mohsin,
    please refer to the below ....
    might be helpful for u .....
    https://scn.sap.com/thread/2050188
    http://scn.sap.com/message/6407195
    http://r0005001.benxbrain.com/de%28bD1lbiZjPTAwMQ==%29/index.do?onInputProcessing=brai_thread&001_thread_id=1759814%20&001_temp=R3TR|PROG|RCSBI010||P01|
    Hope thiw will help ....
    Regards,
    AKS

  • Using depth first traversal to add a new node to a tree with labels

    Hello,
    I'm currently trying to work my way through Java and need some advice on using and traversing trees. I've written a basic JTree program, which allows the user to add and delete nodes. Each new node is labelled in a sequential order and not dependent upon where they are added to the tree.
    Basically, what is the best way to add and delete these new nodes with labels that reflect their position in the tree in a depth-first traversal?
    ie: the new node's label will correctly reflect its position in the tree and the other labels will change to reflect this addition of a new node.
    I've searched Google and can't seem to find any appropriate examples for this case.
    My current code is as follows,
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.event.*;
    import javax.swing.tree.*;
    public class BasicTreeAddDelete extends JFrame implements ActionListener
        private JTree tree;
        private DefaultTreeModel treeModel;
        private JButton addButton;
        private JButton deleteButton;
        private int newNodeSuffix = 1;
        public BasicTreeAddDelete() 
            setTitle("Basic Tree with Add and Delete Buttons");
            DefaultMutableTreeNode rootNode = new DefaultMutableTreeNode("Root");
            treeModel = new DefaultTreeModel(rootNode);
            tree = new JTree(treeModel);
            JScrollPane scrollPane = new JScrollPane(tree);
            getContentPane().add(scrollPane, BorderLayout.CENTER);
            JPanel panel = new JPanel();
            addButton = new JButton("Add Node");
            addButton.addActionListener(this);
            panel.add(addButton);
            getContentPane().add(panel, BorderLayout.SOUTH);
            deleteButton = new JButton("Delete Node");
            deleteButton.addActionListener(this);
            panel.add(deleteButton);
            getContentPane().add(panel, BorderLayout.SOUTH);    
            setDefaultCloseOperation(EXIT_ON_CLOSE);
            setSize(400, 300);
            setVisible(true);
        public void actionPerformed(ActionEvent event) 
            DefaultMutableTreeNode selectedNode = (DefaultMutableTreeNode)tree.getLastSelectedPathComponent();
            if(event.getSource().equals(addButton))
                if (selectedNode != null)
                    // add the new node as a child of a selected node at the end
                    DefaultMutableTreeNode newNode = new DefaultMutableTreeNode("New Node" + newNodeSuffix++);
                      treeModel.insertNodeInto(newNode, selectedNode, selectedNode.getChildCount());
                      //make the node visible by scrolling to it
                    TreeNode[] totalNodes = treeModel.getPathToRoot(newNode);
                    TreePath path = new TreePath(totalNodes);
                    tree.scrollPathToVisible(path);               
            else if(event.getSource().equals(deleteButton))
                //remove the selected node, except the parent node
                removeSelectedNode();           
        public void removeSelectedNode()
            DefaultMutableTreeNode selectedNode = (DefaultMutableTreeNode)tree.getLastSelectedPathComponent();
            if (selectedNode != null)
                //get the parent of the selected node
                MutableTreeNode parent = (MutableTreeNode)(selectedNode.getParent());
                // if the parent is not null
                if (parent != null)
                    //remove the node from the parent
                    treeModel.removeNodeFromParent(selectedNode);
        public static void main(String[] arg) 
            BasicTreeAddDelete basicTree = new BasicTreeAddDelete();
    }      Thank you for any help.

    > Has anybody got any advice, help or know of any
    examples for this sort of problem.
    Thank you.
    Check this site: http://www.apl.jhu.edu/~hall/java/Swing-Tutorial/Swing-Tutorial-JTree.html

  • I add some node to a tree but it is not shown in web page.

    Hi
    thank you for reading my post.
    I read some tutorial in the web and i add some tree node to a tree dynamically.
    but none of them is shown :(.
    I should say that i write the code that create a tree in session scope bean because my tree is placed in a fragment and fragment has no preRender method.
    here is code that initiate a tree, and i think it is correct.
        public void initiateTree() {
            getTree1().setClientSide(true);       
            System.out.println("Setter called");
            Context ctx=null;
            DataSource ds=null ;
            Connection con=null ;
            Statement st = null ;
            List rootMenuItems = new ArrayList();
            ResultSet rs = null;
            try {
                ctx = new InitialContext();
                ds= (DataSource) ctx.lookup("java:comp/env/jdbc/dataSource");
                con= ds.getConnection();
                st= con.createStatement();
            } catch (Exception ex) {
                ex.printStackTrace();
            try {
                java.sql.PreparedStatement childsPSt  = con.prepareStatement("select * from categories where parentcategory = ?");
                rs=  st.executeQuery("select * from categories where parentcategory= 0 and language = " +"'"+getLang()+"'");
                //roots
              while(rs.next()){
                  int parentID = rs.getInt("categoryID");
                                System.out.println("A root has been added   "+parentID );
    TreeNode aRootNode =  new TreeNode();
    aRootNode.setText(rs.getString("categoryname"));
                //childs
                    childsPSt.setInt(1,parentID);
                    ResultSet cRs = childsPSt.executeQuery();
                    while(cRs.next()){
                        System.out.println("Achild has been added "+ cRs.getString("categoryname")+ " " + parentID);
    TreeNode childNode = new TreeNode();
    childNode.setText(cRs.getString("categoryname"));
    aRootNode.getChildren().add(childNode);
    getTree1().getChildren().add(aRootNode);
            } catch (SQLException ex) {
                ex.printStackTrace();
       I call this method in session bean constructor.
    here is code that bind the tree in page fragment to session bean tree1
                <ui:tree binding="#{SessionBean1.tree1}" id="tree1" style="height: 167px"/>here is console output that prove the initiate method do some works.
    Setter called
    A root has been added   1
    Achild has been added cat name 2  1
    Achild has been added cat name 3 1
    A root has been added   5

    i think u need to add hyperlink component to the node thus cause node must carry hyperlink or anything u like to add like staticText or checkBox ....
    add this code after creation the aRootNode and childNode
    it may works :)
    Hyperlink h = new Hyperlink();
    h.setText(cRs.getString("categoryname"));
    childNode .getFacets().put( childNode .CONTENT_FACET_KEY, h );

  • Add checkbox on the nodes of Hierarchical tree in oracle forms 9i

    Hi,
    I am working on oracle forms 9i.I have to add checkbox at the place of node(+/-) in Hierarchical tree so,
    that user can select or deselect the Tree.That can do in oracle forms but how i don't know.
    can anybody help me.....
    Regards,
    Hemant

    You can't change this aspect of the Tree Control in Oracle Forms using built-in functionality. You might be able to extend the Tree Control using Java, but you have to do this yourself. : (
    Craig...

  • Programmatic, using bean add Parent and child nodes in af:tree dynamically

    Hi All,
    i have to add parent and child nodes dynamically in tree .
    Example :
    i have created a tree like below.On click of button i will get value A ,from pl/sql function i will A1 and A 2 values.which i have to show in pop as tree.
    A
    |-----A1
    |-----A2
    If user clicks on A2.I have to catch A2 value and pass to pl/sql function which gives A2.01 and A2.02 values.
    A
    |-----A1
    |-----A2
    |------A2.01
    |------A2.02.
    A, A1 ,A2,A2.01 ...........values comes from pl/sql funchtion .
    thanks in advance ......... any suggestion will greatly helps

    no use ......................

  • How to add node in tree.

    hi all
    I want to add a new node to tree. Can we add new node to a tree? plz help me out.
    sarah

    hi Arun.
    My code will be something like this.
    DECLARE
    htree ITEM;
    rg_data RECORDGROUP;
    BEGIN
    -- Find the tree itself.
    htree := Find_Item('control.emp_tree');
    -- Find the record group.
    rg_data := FIND_GROUP('rg1');
    -- Add the new node at the top level and children.
    Ftree.Add_Tree_Data(htree,
    Ftree.ROOT_NODE,
    Ftree.PARENT_OFFSET,
    Ftree.LAST_CHILD,
    Ftree.RECORD_GROUP,
    rg_data);
    END;
    if i use add_tree but i think it will add all the same nodes down. guide me plz. i am confused.
    sarah

  • Program to add node /  delete node in the tree control via abap object

    Hi all,
    i am new to abap objects.
    Can anyone help me out to give program about add node , delete node at
    a particular point in tree hierarchy.
    folder1                     -- level 1
    subfolder1          -- level 2
    *********subfolder1   -- level 3
    *********subfolder2  -- level 3
    subfolder2          -- level 2
    folder2                     -- level 1
    if i select level3 and click on ADD button .....i get a facility to add new node
    at level 3 and and same thing can happen at level1 and level2 ............ if i select
    and folder at level3 and click on delete button ....it should delete that folder...
    if you do not have such program ........then guide me how to achieve this target via object oriented because i have to split the screen also and have to show some alve display in that.
    just guide me how to add and delete node at a particular level in tree structure....
    thanks in advance........

    Hello Ravi,
    Try this demo program:
    <b>BCALV_TREE_01</b>
    <b>BCALV_TREE_DEMO</b>
    BCALV_TREE_SIMPLE_DEMO
    Also try:
    BCALV_TREE_02
    BCALV_TREE_03
    BCALV_TREE_04
    BCALV_TREE_05
    BCALV_TREE_06
    regards,
    Beejal
    **reward if this helps

  • Macking button to expand the tree and collapse tree and another to add node

    macking button to expand the tree and collapse tree and another to add node and saving the changes in the database ( this is problem)
    and finally delete node from database
    so what is proper code for those buttons
    thanks my mail is :
    [email protected]

    Hello,
    Use the ftree package's functions
    code to expand all nodes:
    PROCEDURE explose_tree IS
    node    ftree.node;
    htree   ITEM;
    state   varchar2(30);
    BEGIN
       -- search the tree ID --
       htree := Find_Item('BL_TREE.TREE_1');
        -- search the root --
           node  := Ftree.Find_Tree_Node(htree, '');
        -- expand all nodes --
       WHILE NOT Ftree.ID_NULL(node) LOOP
          state := Ftree.Get_Tree_Node_Property(htree, node, Ftree.NODE_STATE);
          IF state = Ftree.COLLAPSED_NODE THEN
            Ftree.Set_Tree_Node_Property(htree, node, Ftree.NODE_STATE, Ftree.EXPANDED_NODE);
          END IF;
          node := Ftree.Find_Tree_Node(htree, '', ftree.find_NEXT,Ftree.NODE_LABEL,'', node);
       END LOOP;
    END;and to collapse all nodes:
    PROCEDURE Implose_tree IS
       node   ftree.node;
       htree  ITEM;
       state  varchar2(30);
    BEGIN
       -- search the root ID --
       htree := Find_Item('BL_TREE.TREE_1'); 
       -- search the root --
       node  := Ftree.Find_Tree_Node(htree, '');  
       -- Collapse all nodes --
       WHILE NOT ftree.ID_NULL(node) LOOP
         state := Ftree.Get_Tree_Node_Property(htree, node, Ftree.NODE_STATE);
         IF state = Ftree.EXPANDED_NODE THEN
          Ftree.Set_Tree_Node_Property(htree, node, Ftree.NODE_STATE, Ftree.COLLAPSED_NODE);
         END IF;
        node := Ftree.Find_Tree_Node(htree, '', Ftree.FIND_NEXT,Ftree.NODE_LABEL, '', node);
       END LOOP;
    END; Francois

  • Add a button after each node of my tree

    Hi !
    I would like to add a button after each node of my tree. I think I have to create a new TreeCelleRenderer but I really don't know how to make it. Can someone help me and give me an idea (or an example !) about the code.
    When I click the button, I must know from which node the event comes.
    thanks.
    delph

    Hi, how did you resolve the problem. Well it's long time from your posting, but maybe someone else can help me...
    I'm creating similar JTree where's print and save buttons in some of the nodes. I created custom cell renderer which extends JPanel and holds images, text and the buttons inside it. Is it possible to link buttons' actionlisteners somehow to the nodes. I tried it customizing cell editor, but I can't get button events fired. I also tried to catch "button clicked" action using mouse listener in my tree and that worked somehow and can be used as quick and dirty solution. Still I want to do it better way.
    -e

  • Letting a user add a node to a tree

    Hi,
    Currently I have a tree that is built dynamically with a
    remote object call. Also, if the user clicks on a node, a menu pops
    up allowing the user to create a child for the node. How do I let
    the user add a node to the tree ? I saw tangential examples showing
    how to add xml nodes, but I am unable to translate that to trees
    that are populated NOT in static xml, but from a remote object
    call.
    I have the following function signature :
    // parentIndex - the index of the parent node, where the user
    wants to add a child node
    // childLabel - the label for the child node.
    private addChild(parentIndex:int, childLabel:String) {
    Thanks for your help.

    Hi Tracy, this the code I am using from PeterEnt's blog. His
    example was about drag-and-drop. I am trying to use it (maybe I
    shouldn't:) for my child node insertion.
    myTree.selectedIndex = parentIndex;
    var node:XML = myTree.selectedItem as XML; // interestingly,
    myTree.selectedItem is not null, but node is null. Why ?
    var p:*;
    if(myTree.dataDescriptor.hasChildren(node)) {
    p = node;
    parentIndex = 0;
    else { // I am getting a null pointer exception here
    p = node.parent();
    var insert:XML = <node />;
    insert.@label = "New Toy";
    insert.@type = "Toy";
    myTree.dataDescriptor.addChildAt(p, insert, parentIndex+1);
    I am getting the parent value (label etc) correctly for
    myTree.selectedItem. But when I do node:XML = myTree.selectedItem
    as XML, I am getting null value for null. That's why I asked in my
    first message if there is a difference in populating the data
    statically as XML v.s. loading the data using remote object (which
    is the case here).
    Appreciate your help.

  • How to dynamically add Nodes to JTree?

    How to add nodes to a Jtree by getting the information into a specific file
    For example, in JList:
    DefaultListModel workgroups;
    workgroups = new DefaultListModel();
    List<String> workgroupsList = new ArrayList<String>();
    workgroupsList = ParserUtils.getWorkgroupList(ParserUtils.getConfigPath() + "\\.workgroup.properties");
    if (!workgroupsList.isEmpty()){
         for (String workgroup : workgroupsList){
              workgroups.addElement(workgroup.toString().trim());
    workgroupList = new JList(workgroups); //adds the list workgroupsThe output of this will be a JList displaying the list of workgroups per line. The list could be found in a file name "workgroup.properties"
    Question is, is it possible to adapt this same method in JTree. The information per line will serve as one node in the tree. For example, I have 3 workgroups in the list, there will also be 3 nodes to be found in the tree.
    Any suggestions?
    THanks.

    There's a huge JTree example in the Swing tutorial. It's a bit of a beast to use.

  • Can't remove a node from a tree

    I am using the custom tree dataDescriptor provided in Flex live
    doc. It works for creating the tree and add notes, however when I
    try to remove a node from the tree it cant work. Does anyone have
    any idea?
    This is the code for MyCustomeTreeDataDescriptor.as
    package
    import mx.collections.ArrayCollection;
    import mx.collections.CursorBookmark;
    import mx.collections.ICollectionView;
    import mx.collections.IViewCursor;
    import mx.events.CollectionEvent;
    import mx.events.CollectionEventKind;
    import mx.controls.treeClasses.*;
    public class MyCustomTreeDataDescriptor implements
    ITreeDataDescriptor
    // The getChildren method requires the node to be an Object
    // with a children field.
    // If the field contains an ArrayCollection, it returns the
    field
    // Otherwise, it wraps the field in an ArrayCollection.
    public function getChildren(node:Object,
    model:Object=null):ICollectionView
    try
    if (node is Object) {
    if(node.children is ArrayCollection){
    return node.children;
    }else{
    return new ArrayCollection(node.children);
    catch (e:Error) {
    trace("[Descriptor] exception checking for getChildren");
    return null;
    // The isBranch method simply returns true if the node is an
    // Object with a children field.
    // It does not support empty branches, but does support null
    children
    // fields.
    public function isBranch(node:Object,
    model:Object=null):Boolean {
    try {
    if (node is Object) {
    if (node.children != null) {
    return true;
    catch (e:Error) {
    trace("[Descriptor] exception checking for isBranch");
    return false;
    // The hasChildren method Returns true if the node actually
    has children.
    public function hasChildren(node:Object,
    model:Object=null):Boolean {
    if (node == null)
    return false;
    var children:ICollectionView = getChildren(node, model);
    try {
    if (children.length > 0)
    return true;
    catch (e:Error) {
    return false;
    // The getData method simply returns the node as an Object.
    public function getData(node:Object,
    model:Object=null):Object {
    try {
    return node;
    catch (e:Error) {
    return null;
    // The addChildAt method does the following:
    // If the parent parameter is null or undefined, inserts
    // the child parameter as the first child of the model
    parameter.
    // If the parent parameter is an Object and has a children
    field,
    // adds the child parameter to it at the index parameter
    location.
    // It does not add a child to a terminal node if it does not
    have
    // a children field.
    public function addChildAt(parent:Object, child:Object,
    index:int,
    model:Object=null):Boolean {
    var event:CollectionEvent = new
    CollectionEvent(CollectionEvent.COLLECTION_CHANGE);
    event.kind = CollectionEventKind.ADD;
    event.items = [child];
    event.location = index;
    if (!parent) {
    var iterator:IViewCursor = model.createCursor();
    iterator.seek(CursorBookmark.FIRST, index);
    iterator.insert(child);
    else if (parent is Object) {
    if (parent.children != null) {
    if(parent.children is ArrayCollection) {
    parent.children.addItemAt(child, index);
    if (model){
    model.dispatchEvent(event);
    model.itemUpdated(parent);
    return true;
    else {
    parent.children.splice(index, 0, child);
    if (model)
    model.dispatchEvent(event);
    return true;
    return false;
    // The removeChildAt method does the following:
    // If the parent parameter is null or undefined, removes
    // the child at the specified index in the model.
    // If the parent parameter is an Object and has a children
    field,
    // removes the child at the index parameter location in the
    parent.
    public function removeChildAt(parent:Object, child:Object,
    index:int, model:Object=null):Boolean
    var event:CollectionEvent = new
    CollectionEvent(CollectionEvent.COLLECTION_CHANGE);
    event.kind = CollectionEventKind.REMOVE;
    event.items = [child];
    event.location = index;
    //handle top level where there is no parent
    if (!parent)
    var iterator:IViewCursor = model.createCursor();
    iterator.seek(CursorBookmark.FIRST, index);
    iterator.remove();
    if (model)
    model.dispatchEvent(event);
    return true;
    else if (parent is Object)
    if (parent.children != undefined)
    parent.children.splice(index, 1);
    if (model)
    model.dispatchEvent(event);
    return true;
    return false;
    This is my tree definition:
    <mx:Tree width="143" top="0" bottom="0" left="0"
    height="100%"
    id="publicCaseTree"
    dataDescriptor="{new MyCustomTreeDataDescriptor()}"
    dataProvider="{ac}"
    defaultLeafIcon="@Embed('assets/caseIcon.png')"
    change="publicTreeChanged(event)"
    dragEnabled="true"
    dragMoveEnabled="false"/>
    This is how I remove the selected node from the tree. When
    Delete button is clicked, the doDeleteCase function is
    exectuted.
    public function publicTreeChanged(event:Event):void {
    selectedNode =
    publicCaseTree.dataDescriptor.getData(Tree(event.target).selectedItem,
    ac);
    public function doDeleteCase(event:Event):void{
    publicCaseTree.dataDescriptor.removeChildAt(publicCaseTree.firstVisibleItem,
    selectedNode, 0, ac);
    Any help would be appreciated.Thanks.

    Finally I removed nodes from tree, but not sure I did in the
    right way. Anybody encounter the same problem, please
    discuss.

Maybe you are looking for

  • How to delete an active change version of a PO?

    Hi all mates, question: given a PO number, assuming that the active version is a change one and the previous version has been ordered (I don't know if this is the proper word: I mean "transferred to the backend" (R/3))... is there a simple way, e.g,

  • Opening folders in the same tab???

    I'm fairly new to Macs and I have a question. I currently run OS 10.5.3. I know that for security reasons (i.e. not accidentally deleting something) that when you open folders in Finder that the default setting is to open each folder in a different w

  • CONVERT SCANNED FILE TO PDF AND SEND TO EMAIL!

    I got many files that were scanned in (110) to be exact.  I need to know how to convert the scanned files to pdf and then send them to an email.  Thanks      Marie

  • Trigger to Send Seperate Emails per Address on New Subscricption Insert

    Hi Everyone, I am trying to create a trigger that, on insert into and delete from a email_subscription table, will send an email to our MailMan server to subscribe or unsubscribe a member for each email address they have. The problem is I am not sure

  • EXTERNAL HARD DRIVE CUTS OUT RANDOMLY

    Forum, While in working in FCP, my external hard drive (G-Raid 2) keeps cutting out - 3 times in the past few hours. I think it's a bad connection, but I'm not sure. Any tips? Thank you, Trey