Help of the tree

Hello
I wonder if someone can help me. I'm looking to use a tree for the following structure (keys to show how work tables):

We have three main tables:
* users (pk: user_id)
* roles (pk: role_id)
* groups (pk: group_id)

A user can have multiple roles, a role can have multiple groups, there are two tables of join:
* users_roles (pk: ur_id, fk:user_id, fk:role_id)
* group_roles(pk:gr_id,fk:group_id,gk:role_id)

I want to have a tree that has a list of users that I can develop to show me the list of roles that the user has. Then I can expand the role and see the groups assigned to this role. Is this possible?

I have the SQL code that performs table joins etc (if I can see what are the user roles is, groups in these roles) but I am unable to this card in the tree component.

Any help is appreciated.


Thank you

Hello

I have not tried this yet, but you can have an ID and a PID for each record in a tree, you must create a SQL statement that adds users, roles, and groups as if they were all of the same type. Assuming your PK from 1, you need to create pseudo ID and PID in order to maintain the correct structure. Something like:

select 1 ID,
NULL PID,
'Root' NAME,
NULL LINK
FROM DUAL
UNION ALL
select USER_ID ID,
1 PID,
USERNAME NAME,
NULL LINK
FROM USERS
UNION ALL
ROLE_ID + 1000000 ID,
USER_ID PID,
ROLENAME NAME,
NULL LINK
FROM ROLES
UNION ALL
GROUP_ID + 2000000 ID,
ROLE_ID + 1000000 PID
GROUPNAME NAME,
NULL LINK
FROM GROUPS

The first element is a pseudo root element because, I guess, there is no structure to the users themselves, so we need to have a component root as the parent for all users.

Andy

Tags: Database

Similar Questions

  • Help in the tree like structure

    Hi I need help in creating a tree like structure with 2 sets of data IE parents and children

    Parent is derived from a series of paintings which, in turn, can have parents of void
    something like.

    P1
    -P2
    -P3
    P4

    Child totally resides on another table and will be associated with its parent.

    So that's how my output should be.

    P1
    -P2
    -C1
    -P3
    -C2
    P4
    -C3


    These 2 are 2 different table games, each carrying different set of information, I would like to know how to merge to return as a single registration.

    can someone help me please! I am using Oracle 10 g V 10.2.03

    Published by: Fabien on April 1st, 2010 21:01

    Published by: Fabien on April 1st, 2010 21:04

    Hello

    If some lines of output will come from a table, and other lines of output will come from another table. This sounds like a job for the UNION.
    Consolidate all relevant data in a 'table' before making the CONNECTION BY:

    WITH     union_data     AS
    (
         SELECT     pid     AS node_id
         ,     name
         ,     parent_id
         ,     'P'     AS table_id
         FROM     parent
         --
        UNION ALL
         --
         SELECT     cid     AS node_id
         ,     name
         ,     parent_id
         ,     'C'     AS table_id
         FROM     child
    )
    SELECT     ROWNUM     AS id
    ,     name
    ,     CASE
              WHEN  CONNECT_BY_ISLEAF = 1
              THEN  'N'
              ELSE  'Y'
         END     AS child_indicator
    FROM     union_data
    START WITH     parent_id     IS NULL
    CONNECT BY     parent_id     = PRIOR node_id
         AND     'P'          = PRIOR table_id
    ;
    

    Output from the example of data you posted:

    .       ID NAME       CHILD_INDICATOR
    ---------- ---------- ---------------
             1 P1         Y
             2 P2         Y
             3 C1         N
             4 P3         Y
             5 C2         N
             6 P4         Y
             7 C3         N
    
  • Need help do the elements of dynamic tree

    The news is that I decided that a Treeview would be better suited for a Properties window I design as part of a larger project. I'm thinking about a way to dynamically add treeitem elements to the tree by clicking on a button. (inside an action event block basically) But the API gives some fairly mundane and static means to use it. It assumes that the tree does just before it is displayed and all the elements are static or reading a file before the tree is initialized it doesn't seem to be an obvious way to add treeitem elements to TreeView after its manufacture.
    Here's what the API shows in his example:

    (http://docs.oracle.com/javafx/2/api/index.html)

    TreeItem < String > root = new TreeItem < String > ("root node");
    root.setExpanded (true);
    root.getChildren (.addAll)
    New TreeItem < String > ("Item 1"),
    New TreeItem < String > ("Item 2"),
    New TreeItem < String > ("Item 3")
    );
    TreeView TreeView < String > is new TreeView < String > (root);.



    Again, its only done at the end I need a way to add treeitem elements on the fly (in response to an event).


    I use a .fxml, a controller of java and Netbeans. If that helps.

    You can call

    treeItem.getChildren().add(...);
    

    or

    treeItem.getChildren().remove(...);
    

    or indeed other methods that manipulate the content of the list of the tree at any time on the FX application thread.

    Thus, for example:

    TreeExample.fxml:

    
    
    
    
    
    
    
    
    
         

    TreeExampleController.java:

    import javafx.beans.binding.BooleanBinding;
    import javafx.fxml.FXML;
    import javafx.scene.control.Button;
    import javafx.scene.control.TreeItem;
    import javafx.scene.control.TreeView;
    
    public class TreeExampleController {
      private @FXML TreeView tree ;
      private @FXML Button addButton ;
      private @FXML Button removeButton ;
    
      private int count ;
    
      public void initialize() {
        removeButton.disableProperty().bind(new BooleanBinding() {
          {
            super.bind(tree.getSelectionModel().selectedItemProperty());
          }
          @Override
          protected boolean computeValue() {
            TreeItem selectedNode = tree.getSelectionModel().getSelectedItem();
            return selectedNode == null || selectedNode == tree.getRoot();
          }
    
        });
        count = 1 ;
      }
    
      public void addNode() {
        TreeItem parent = tree.getSelectionModel().getSelectedItem();
        if (parent==null) {
          parent = tree.getRoot();
        }
        count++ ;
        final TreeItem newNode = new TreeItem("Node "+count);
        parent.getChildren().add(newNode);
        parent.setExpanded(true);
        tree.getSelectionModel().select(newNode);
      }
    
      public void removeNode() {
        TreeItem selectedNode = tree.getSelectionModel().getSelectedItem();
        if (selectedNode != null) {
          TreeItem parentNode = selectedNode.getParent();
          if (parentNode != null) {
            parentNode.getChildren().remove(selectedNode);
          }
        }
      }
    }
    

    and TreeExample.java:

    import javafx.application.Application;
    import javafx.fxml.FXMLLoader;
    import javafx.scene.Parent;
    import javafx.scene.Scene;
    import javafx.stage.Stage;
    
    public class TreeExample extends Application {
    
      @Override
      public void start(Stage primaryStage) throws Exception {
        Parent root = FXMLLoader.load(getClass().getResource("TreeExample.fxml"));
        Scene scene = new Scene(root, 600, 400);
        primaryStage.setScene(scene);
        primaryStage.sizeToScene();
        primaryStage.show();
      }
    
      /**
       * @param args
       */
      public static void main(String[] args) {
        launch(args);
      }
    
    }
    

    Select the nodes and add children or delete to your heart's content...

  • Help with the drawing of a recursive tree

    Hello
    I tried to draw a kind of recursive tree similar to this , but I got stuck. I can not write the actual recursion and I ask for some help how to.
    import java.awt.*;
    import javax.swing.*;
    
    public class Tree extends JPanel{
    
         static void drawTree(Graphics2D g, int n, int x, int y,
                                          int x1, int y1, int x2, int  y2, int x3, int y3){
              
              if(n==0){
                   return;
              }
              else{
                   g.setColor(Color.BLUE);
                   g.translate(x, y);     // Moves to center of the screen
                   g.rotate(180*Math.PI/180);
                   g.drawLine(0, 0, x1, y1);
                   g.drawLine(0, 0, x2, y2);     // Draws main three lines
                   g.drawLine(0, 0, x3, y3);
                   g.rotate(-180*Math.PI/180);     // Still at the center
                   
                   g.translate(-x1, -y1);     // Moves to the top of the left line
                   g.rotate(150*Math.PI/180);
                   g.drawLine(0, 0, x1/2, y1/2);
                   g.drawLine(0, 0, x2/2, y2/2);     // Draws first combination
                   g.drawLine(0, 0, x3/2, y3/2);
                   g.rotate(-150*Math.PI/180);
                   g.translate(x1, y1);     // Moves back to center
                   
                   g.translate(-x2, -y2);     // Moves to the top of the middle line
                   g.rotate(180*Math.PI/180);
                   g.drawLine(0, 0, x1/3, y1/3);
                   g.drawLine(0, 0, x2/3, y2/3);     // Draws second combination
                   g.drawLine(0, 0, x3/3, y3/3);
                   g.rotate(-180*Math.PI/180);
                   g.translate(x2, y2);     // Moves back to center
                   
                   g.translate(-x3, -y3);     // Moves to the top of the right line
                   g.rotate(210*Math.PI/180);
                   g.drawLine(0, 0, x1/2, y1/2);
                   g.drawLine(0, 0, x2/2, y2/2);     // Draws third combination
                   g.drawLine(0, 0, x3/2, y3/2);
                   g.rotate(-210*Math.PI/180);
                   g.translate(x3, y3);     // Moves back to center
                   
                   g.setColor(Color.RED);
                   g.drawLine(0, 0, 50, 0);
                   g.drawLine(0, 0, 0, 50); // Draws coordinate system just for my reference
                   g.drawLine(0, 0, -50, 0);
                   
              }
              
         }
         
         protected void paintComponent(Graphics g){
              super.paintComponent(g);
              
              drawTree((Graphics2D)g, 5, getWidth()/2, getHeight()/2, 40, 20, 10, 15, -40, 20 );
              
         }
         
         
         public static void main(String[] args) {
              
              Tree panel = new Tree();
              JFrame app = new JFrame("Tree");
              
              app.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              app.add(panel);
              app.setSize(500, 500);
              app.setVisible(true);
         }
    
    }
    For now, I'm worried about the stem. Just the branches.

    Any help/advice is greatly appreciated.

    Published by: Luke on May 1st, 2011 17:04

    Luke wrote:
    The left branches seem to decrease length very well when I go deep.

    But there are two problems that I don't know how fix - length of branches straight is too much decreasing and they are misplaced. The other thing is that when I

    maximize/minimize the window containing the graph the image becomes smaller and smaller until it becomes a small point.

    You are far too complicated. But the static variable can actually help you visualize how the tree is painted. run the program below to see.

    I set a goal:
    -Each recursive call must paint a line 10 pixels of length less than the forward direction. Specifically in the program below should be the length
    line 1: 100px
    line 2, 5: 90px
    line 3, 4, 6, 7: 80px
    -You can use n, x and y to the length calculated
    -You can add additional parameters to the draw method
    -You are not allowed to use instance variables (you can leave the variable count for debugging)
    -You are not allowed to use the static keyword anywhere
    -You have to give the result of each calculation a descriptive name

    // For example not:
    draw((Graphics2D) g, 3, getWidth() / 2, getHeight() / 2);
    // but
    int depth = 3;
    int centerHorizontally = getWidth() / 2;
    int centerVertically = getHeight() / 2;
    draw((Graphics2D) g, depth, centerHorizontally, centerVertically);
    
    import java.awt.*;
    import javax.swing.*;
    
    public class Tree extends JPanel {
    
        private int count;
    
        private void draw(Graphics2D g, int n, int x, int y) {
            if (n == 0) {
                return;
            }
            else {
                int angle = 35;
                int length = 50;
                count++;
    
                g.drawLine(x, y, x, y - length); // trunk
                g.setColor(Color.RED);
                g.drawString(String.valueOf(count), x + 2, y - (length / 2));
                g.setColor(Color.BLACK);
    
                g.rotate(Math.toRadians(-angle), x, y - length); // left
                                                                         // branch
                draw(g, n - 1, x, y - length);
                g.rotate(Math.toRadians(angle), x, y - length);
    
                g.rotate(Math.toRadians(angle), x, y - length); // right
                                                                        // branch
                draw(g, n - 1, x, y - length);
                g.rotate(Math.toRadians(-angle), x, y - length);
    
            }
        }
    
        @Override
        protected void paintComponent(Graphics g) {
            super.paintComponent(g);
            count = 0;
    
            Graphics2D gg = (Graphics2D) g;
            gg.setFont(gg.getFont().deriveFont(Font.BOLD, 16f));
            gg.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
                    RenderingHints.VALUE_ANTIALIAS_ON);
            draw(gg, 3, getWidth() / 2, getHeight() / 2);
        }
    
        public static void main(String[] args) {
            EventQueue.invokeLater(new Runnable() {
                public void run() {
                    Tree tree = new Tree();
                    tree.setPreferredSize(new Dimension(500, 500));
    
                    JFrame frame = new JFrame("Test");
                    frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
                    frame.getContentPane().add(tree);
                    frame.pack();
                    frame.setLocationRelativeTo(null);
                    frame.setVisible(true);
                }
            });
        }
    }
    

    Published by: Walter Laan 11 May 2011 21:58 (a little more readable numbers :))

  • With the help of the police included in the tree control

    Hello

    I am trying to use embedded font to change the font family for a control tree but hopeless, I tested the police embedded with a label component and it worked well, but for the tree control, I couldn't succeed.

    Can anyone help with this, don't--what someone has any idea?

    You must embed the version "BOLD" to the police as well.

  • Max of tasks is does not display in the tree

    I don't know if it's good advice or not, but it is not a Council of MAX.

    I'm having a problem in Max where I can create a new task, save it and it does not appear in the tree of the task, but I can access in the browser window in Labview. I attach 2 images below to show the problem. Thanks in advance for your help

    This looks like a MAX Database corruption problem, the following link contains steps on how to fix corruption of the database:

    http://digital.NI.com/public.nsf/allkb/2C7480E856987FFF862573AE005AB0D9?OpenDocument

    Let me know if it works for you.

    Nathan P.

  • Adding items to the tree in an effective way

    Hello

    I am trying to add items in the tree.

    The problem I am facing is, I have to update the tree constantly and add elments.

    To add first items bit it takes less time, but as the tree grows the accumlated gets.

    Demo Vi is attached for reference.

    Any HELP WILL BE GREATFUL. (vi ATTACHED IS in 2009 version)

    First of all, 1% for calibration of time Windows is 'no difference '.

    But indeed, the update of the front panel is not the factor limiting here: this is the number of children-entries that create problems. So with zero children (as I did in my first test), to postpone the updates done grant you a huge performance increase as is the one and only overhead.

    In your case (100 children), defer updates is disabled the relevance as the method 'Add items' takes awhile.

    I agree that the performance impact is huge, maybe too big, to increase the number of children. But on the other hand, you must understand that you are dealing with arrays of cluster... is in fact a big effort for the memory manager to allocate enough memory, copy of things around and (internally) the deallocation of memory. It's the more data, the most important, this will create. Therefore, it will get slower the more data that you add. But certainly, the measure is surprisingly high.

    But nothing you can change.

    To the last comment: why do you need a tree that changes many times during execution while maintaining several 100ths of elements in any combination of parent/child?

    Norbert

  • MAX: Devices &amp; Interfaces missing from the tree?

    Hi all

    I'm a noob and try to learn LV

    I'm working through the book, Labview for everyone, and I work in the chapter on the instrument control.

    I opened MAX (Measurement and Automation Explorer) and want to see the ports on my computer.

    It is said in the book and local help, click on the link devices and Interfaces in the tree view on the left hand side... but I do not see this option. All I see is

    My system

    Software

    IVI drivers

    Remote systems

    Is there anything else I need to install? I looked on the installation disk and I don't see anything else?  I'm going to need to talk via USB / RS232 / serial port to communicate with a Board I'll receive it soon...

    Can someone give me some advice on what I should get get the devices and Interfaces > Ports on MAX?

    I looked on the forum here and I've seen people with the same problems that had not installed a NI-VISA. I have check and it seems that I do:

    NI-VISA 5.0.3

    Duration of NI-VISA 5.0.3

    I'm under LV 2011

    Thank you in advance!

    Cayenne

    It's the wrong version of the VISA for LabVIEW 2011.

    NI-VISA and compatibility of the versions of LabVIEW for Windows

    Be sure to only run records of device driver provided with LabVIEW 2011 after the installation of the 2011 LV.

  • How to increase line spacing between the tree of elements in a modern tree control

    I have a VI where I used a tree of modern pallate control, that I need to increase the space between the elements of the tree. and should be retained, even if I have to add or remove items from the tree

    PS: Property "AutoRowHt" doesn't seem to help here

    Unfortunately, I didn't have time to play with or not this propgates of new entries created in the control tree programmatically, but if not, you could always just to revive this section of code (or specify the specific line because you'll know that the index of the inserted item).

    Specification-2 in the number of line property will specify that the change should be made for all rows in the tree.

  • Is a part of the tree of his own brothers and sisters?

    I have a routine that takes an item in the tree selected by a user and loop through all brothers and sisters of the element:

    itemRelated = TRUE;treeItemToTest = 0;
    
    while ((itemRelated) && (treeItemToTest < totalTreeItems) &&     (treeItemToTest >= 0))
    {
        /* Check if file is related to the selected file */
        AreTreeItemsRelated(panelHandle, treeHandle,
            treeItemToTest, VAL_SIBLING, selectedTreeIndex,
            &itemRelated);
    
        if (itemRelated)
        {
            /* process the item */
            /* ... */
    
            ++treeItemToTest;
        }
    }
    

    Somewhere between the current version and CVI 2012, our program has stopped working properly.  I traced the problem to the call of AreTreeItemsRelated in this routine.  In the latest version of LabWindows, this call returns FALSE if treeItemToTest and selectedTreeIndex are from the same point.  This is apparently a change in behavior of CVI, 2012, but it is not documented in the help of the function.  This change was deliberate?

    Yes. You are right. You have run into a scenario that can be very difficult to work around. We try very hard to never break compatibility with older versions of the execution, but sometimes it's inevitable, as in cases like this where a bug is fixed in a new version. Problems occur when there are existing programs which are assuming the existence of this bug and would actually break if it were not for the bug.

    The best way to avoid this situation is to use a specific flavour to the version of the runtime of the CVI. It has its drawbacks, of course (for example not automatically benefit from bug fixes in the run-time), but he could sure complicated deployment.

    Of course, who isn't really help you now, since your 'program #1' is already deployed using shared execution. Having said that, the best you can do is to replace it, what you can do without uninstalling all of its dependencies, by following these steps.

    Luis

  • Folder is missing in "Libraries" Explorer tree, but present in the tree 'computer '.

    It's hard to describe, please bear with me.  I have a file which, according to him, how to navigate seems to disappear.  If I use Start | Documents and then drill down, when I reached the position in the directory tree where the folder should be, I see a list of all documents that are in the folder, but I don't see the folder itself.

    If I use Start | Computer | C: | Users | | My Documents and zooming in, the folder appears as it should.

    If I go to a CMD prompt and change the directory using the CD command, I can follow the path C:\Users\\Documents\ all the way to the folder and everything seems also very well.  However, if I use CD and follow the C:\Users\\My Documents path, I can't go any further than My Documents.

    If I use 7 - Zip file manager, I follow the same path as with CMD: C:\Users\\Documents works very well, but C:\Users\\My Documents runs into a dead end.

    I think the problem has something to do with "libraries."  I noticed that if the navigation pane of the Explorer on the left side of the screen is 'Computer' has highlighted, the file is displayed as it should, but if the "libraries" are highlighted, it does not appear correctly.

    There is only one folder (at least as far as I could see) that exhibits this behavior.

    I tried searching the forum and the Web for this problem, but it is difficult to characterize in a keyword search, so I did not get anywhere.

    I made sure the file doesn't have a 'hidden' attribute or 'system' defined and generally anchored to try and see what happens, but nothing seems unusual.

    Any help would be greatly appreciated.

    After playing around a bit more, I see that if I down through the tree of libraries in the left navigation pane, the folder appears correctly where it belongs.  It's only when I drill down using the main file view pane that the folder does not contain.

  • Network location using cmd of the tree card

    I currently work for a small company where record us everything on a NAS drive that appears just like any computer in the network.

    We head to a correct server and I would like to be able to print or save the tree of this player, so we can see how all the files are organized.

    Ive been working on how to get the order of the tree out of the tree to a local drive on the computer in a .txt file by using the command:

    /A tree "drive": > tree.txt

    I can work the way I would make the drive the NAS drive on our network, is this possible? I tried the IP addresses and the name of the computer in the place of the C: etc or the reader, but it always seems to try to get inside the computer

    any help would be appreciated

    Try this:

    tree \\192.168.1.20\ShareName > d:\tree.txt

    (use the name correct IP address and hand)

  • Why the tree in Explorer drop down when you open a folder in Windows 7?

    I don't know what kind of joke someone plays, but it is not . I have already most likely to get surgery on both of my hands soon for carpal syndrome severe. For each round of a mouse wheel and all the clicks that I have to endure it's useless, my pain and my symptoms are growing more intense. I have 7 hard drives in my computer. I have search and locate and organize and delete and add files of ALL TIME. I'm in the Explorer of ALL TIME. It is deplorable that I had XP Pro because of threats of compliant. XP has at least had an Explorer who worked perfectly. Now of having to learn a new platform (Windows 7) and I am forced to support a program who has a child of 12 years could have better designed! How long still is * going to go? I discovered only recently that Explorer in Windows 7 has a tree that falls to the bottom of the page fricking every time that a file is opened, so I am forced to dive to the bottom of the page to locate the folder. So I started the research on the forums to see if I was losing my mind and just something wrong. I read messages from people complaining about this BS in 2007. Why is that, after 4 years this perverted arrogant control problem still exists?

    * original title - I just Windows 7.  Why the tree of the menu forsaken God in the Explorer drop down when I open a folder? *

    I just Windows 7. Why the tree of the menu forsaken God in the Explorer drop down when I open a folder?

    This is the Bug of scrolling in the left pane.

    See the bottom of this post for help with the left pane scroll bug using Classic shell.

    Say you want Microsoft fixed it by voting on the Microsoft Connect Web site:

    http://connect.Microsoft.com/WindowsServerFeedback/feedback/details/621426/bug-when-expanding-folders-in-Explorer-Server-2008-R2-and-Windows-7

    Look at the left pane scrolling bug:
    Video testimony of the bug of scrolling in the left pane using Windows Explorer in Windows 7
    This illustrates a way to reproduce it, by clicking on the triangle to expand a folder, that you are currently viewing as it reproduces.

    Son of left pane scroll Bug:

    1 bug: Windows Explorer develops bad records, jumping the folder develop you to the bottom of the navigation pane

    2 tree of Windows explore expands downstairs, not upstairs like it used to be

    3. Windows Explorer navigation pane problem

    4. Explorer moves the folder selected to the bottom of the folder list. How can I stop this?

    5. behavior of strange folder in the left pane of Windows Explorer

    FIX THE BUG IN 10 MINUTES:

    The classic interface mainly eliminates the bug in Windows Explorer, but it will still exist in the open/save dialog boxes.

    Pane left scrolling bug (and other corrections):

    Using the classic interface to restore functionality of Windows Explorer

    After you have installed the free Classic Shell , you can customize Windows Explorer more closely to how you want it, the quote below is just a way to do it. Click here to see some of the options that you can customize, and here is the FAQ page for the classic interface.

    A solution that works for the restoration of some features.

    1) install the free Classic shell.  It's very customizable and works like a mod for Windows Explorer rather than a full blown replacement. You don't need to install the classic Start Menu option, but you can if you wish.
    2) restart the computer.


    3) launch Windows Explorer (Start - computer) and turn on "Always show Menus" (organize - Layout - check menu bar). It's just for the configuration, you can disable it again later if you wish.
    4) right click on the menu bar and turn on the 'Classic Explorer Bar.' This adds a series of icons for cut/copy/paste in Explorer. Basically, it also adds the "Configuration" icon
    5) go in the configuration and from there, you can change things to your heart's content. To kill the horrible record-jumping 7 Windows, place you Vista in 'Style Navigation pane. You can even hit back to XP mode if you want (this adds lines to the tree of folders and adds a classic icon "+" for the expansion of folders). The Windows Vista folder display style looks about the same as the view from Windows 7, but it gets rid of the horrible blow.
    6) adjust other settings you want.

    After that, you can activate the toolbar and menus walk back to explore if you wish. Explorer Windows seems largely the same, but folders is no longer jumping around.  Vote for Microsoft to fix this bug.

    Now if only MS allows to code correctly so that we don't have to mess with third-party applications to get Windows actually works...

    You can also let Microsoft know you want this bug fixed here: http://mymfe.Microsoft.com/Windows%207/feedback.aspx?formid=195

    Note: do not have the message that is too long, there is a size limit for your message, even if page does not tell you on this subject.

  • Need help with Apex tree - 4.2

    Hello everyone. I'm having a problem with a requirement that I was responsible for a tree. I use Apex 4.2, DB 11 g, Classic Blue theme 13. Let me explain what this is and what I'm trying to accomplish.

    Currently, the structure is as follows:

    REQUIREMENT_ID PARENT_REQUIREMENT_ID DESCRIPTION
    1883nullDescription Test 1
    18841883Description Test 2
    1885nullDescription Test 3
    18861884About Test 4

    The query is as follows:

    Select case when connect_by_isleaf = 1 then 0

    When level = 1 then 1

    else                           -1

    end the status,

    level,

    requirement_id | ' - ' || Description as title,

    NULL as an icon,

    requirement_id as value,

    NULL as ToolTip,

    NULL as link

    of xx_requirements

    where project =: p0_project_id

    Start with parent_requirement_id is null

    Connect prior requirement_id = parent_requirement_id

    brothers and sisters of the order by requirement_id

    An excerpt from the result

    Current Tree.JPG

    I was responsible for the increase in the tree by two additional levels with column Module as first column object level, as the second level, and the rest would be what you see above, see Visual below

    Module

    Object

    [Parent] Requirement_ID | ' - '|| Description

    [Children] Requirement_ID | ' - ' || Description

    Module

    Object

    Object

    [Parent] Requirement_ID | ' - '|| Description

    [Children] Requirement_ID | ' - ' || Description

    Object

    REQUIREMENT_ID PARENT_REQUIREMENT_ID DESCRIPTION MODULE TOPIC
    1883nullDescription Test 1INVTopic A
    18841883Description Test 2INVTopic A
    1885nullDescription Test 3OMB.
    18861884About Test 4INVTopic A
    1887nullTest 5 descriptionOMB.

    The above five records should look like this:

    INV

    Topic A

    1883 - description Test 1

    1884 - description Test 2

    1886 - description Test 4

    OM

    B.

    1885 - description Test 3

    1887 - description Test 5

    Can someone help me to achieve this?

    I created a workspace and recreated the current tree + a few other records. It is on page 4 (form on page 5)

    https://Apex.Oracle.com/pls/Apex/f?p=4550:1

    Workspace: APEX_TREE_HELP

    Username: community

    Password: PleaseHelpThanks

    Application: Tree of requirements

    Hi Jennis

    Each node tree in any level must have unique id and specified parent. Your table is deceptively structured. For example topic B, how to determine the parent. Therefore, the table must be structured to get what you want. I've built a table called NEW_REQUIREMENTS with the following structure

    You can find the new code within the region new tree tree

    select case when connect_by_isleaf = 1 then 0
                when level = 1             then 1
                else                           -1
           end as status,
           level,
           case when category = 'DESCRIPTION' then requirement_id || ' - ' || nodename
                else nodename end as title,
           null as icon,
           requirement_id as value,
           null as tooltip,
           null as link
    from new_requirements
    start with parent_requirement_id is null
    connect by prior requirement_id = parent_requirement_id
    order siblings by requirement_id
    

    The result will be like this

    If it solves your problem, please mark it was OK and the thread as answered to help others with the same case

    Concerning

    Mahmoud

  • where clause to query the hierarchy in the tree Apex area does not

    Hi all

    I am building a tree Menu in Apex 5.0.3 (Oracle 11 g XE), when using when the clause, it does show all the data, but without him, showing all the data.

    I'm trying to populate Tree Menu with data specific to a user successfully logged on.

    (A) table created as HR2. TREE_MENU

    menu_name varchar2 (50).

    number of menu_parent

    number of menu_child

    menu_id varchar2 (12),

    menu_path varchar2 (100),

    number of user_no

    (B) SQL statement for the tree in the Apex region

    Select case when connect_by_isleaf = 1 then 0

    When level = 1 then 1

    else                           -1

    end the status,

    level,

    'Menu_name' as the title,

    NULL as an icon,

    "MENU_CHILD" as a value.

    NULL as ToolTip,

    NULL as link

    to HR2. "" TREE_MENU ".

    -WHERE USER_NO =: P_USERNO

    Start with 'MENU_CHILD' is null

    connect prior "MENU_PARENT" = "MENU_CHILD."

    brothers and sisters of order by 'MENU_ID '.

    Note: also used static value where clause but is not workd.

    that the mistake of me or something else? When using the wizard, she asks (possibly) where clause, this means that when the clause can be used in the SQL statement.

    Help, please.

    Kind regards.

    If you want to prune your tree to show only the elements of the No. 7 usermenu, copy the following code helps you

    select case when connect_by_isleaf = 1 then 0
                when level = 1             then 1
                else                           -1
           end as status,
           level,
           "MENU_NAME" as title,
           null as icon,
           "MENU_CHILD" as value,
           null as tooltip,
           null as link
    from HR2."TREE_MENU"
    start with "MENU_CHILD" is null
    connect by
        prior "MENU_PARENT" = "MENU_CHILD"
        and "USER_NO" = 7
    order siblings by "MENU_ID"
    

    Concerning

    Mahmoud

Maybe you are looking for