Highlight the selected Tree Node

Hello Everyone,
Can someone plz tell me how to highlight the selected tree node ?
After selection, user should be able to see which node was last selected.
Thanks

Hello,
for me it is not really clear what you have done. Sorry!
Because I have problems to paste code, I will describe how you can test that function.
Take the BSP application HTMLB_SAMPLES and copy it to ZHTMLB_SAMPLES. Take page "treeviewSample.htm" and add the following node behind node22:
<htmlb:treeNode id   = "node23"
                  text = "Node 2.2, normal text"
                  selection="PRIMARYSELECTION">
Perhaps this will show you how it works and help you.
As far as I can see the attribute "selection" can't be set via table.
Best regads
Renald
Edited by: Renald Wittwer on Jan 21, 2010 1:36 PM

Similar Messages

  • Af:tree - how do I highlight the selected tree node?

    af:tree
    I checked the generated CSS file. I found that when a tree node is selected, the related CSS attribute is:
    .xj:link{
    font-family:Arial,Helvetica,Geneva,sans-serif;
    font-size:10pt;
    font-weight:normal;
    color:#663300
    I created a customized CSS attribute, but then all of the links have the customized CSS attributes.
    How do I just highlight the selected tree node link?
    Thanks,
    --Todd                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

    try doing the onclick javascript method
    you have to place it on the node element and id must be made dynamic
    for this use 'this.id'
    by which the current id of the node is passed
    and by capturing the id name in a var
    use the same for invoking its selected property and make it true
    like this
    var currentid = this.id;
    this.form.currentid.selected = true;

  • How can I edit the selected tree node immediately?

    I have completed a popup menu ,which appeares when I have a mouse rightclicked event
    over the selected tree node.when I selected the popup menu item,i can edit the tree node ,but
    I feel that the tree celleditor appear slowly ,what should i do? the following is my code:
    menuItemRenameNode.addActionListener(new ActionListener()
    public void actionPerformed(ActionEvent ae)
    renameNode_ActionPerformed(ae);
    void renameNode_ActionPerformed(ActionEvent ae){
    setEditable(true);
    this.getCellEditor().addCellEditorListener(new CellEditorListener(){
    public void editingCanceled(ChangeEvent e){
    CellEditor cellEditor =(CellEditor)e.getSource();
    System.out.println("editing canceled:"+cellEditor.getCellEditorValue().toString());
    protected boolean canEditImmediately(EventObject e){
    return true;
    public void editingStopped(ChangeEvent e){
    CellEditor cellEditor =(CellEditor)e.getSource();
    System.out.println("editing stopped:"+cellEditor.getCellEditorValue().toString());

    Please check the suggestions in the thread: https://forums.adobe.com/thread/692020?tstart=0
    Regards,
    | T. Ravi Kumar

  • Retieve the related childern to the selected Tree Node

    Hello all,
    From here i got the folowing code,it helps me to retrieve the whole record which is related to the selected node in
    WHEN-TREE-NODE-SELECTED Trigger :
    declare  
         rank   number := 0;
    begin 
         rank :=
         ftree.get_tree_node_property('TREE_BLOCK_TEST.TREE13', 
             :system.trigger_node, ftree.node_depth);
              if rank >= 1  then
                       GO_BLOCK ('INSP_EQUIPMENT_TYPE');
                      set_block_property ('INSP_EQUIPMENT_TYPE', default_where, 
                            'EQUIPMENT_TYPE_D='||ftree.get_tree_node_property('TREE_BLOCK_TEST.TREE13', 
                               :system.trigger_node, ftree.node_value)); 
                                        Execute_Query(No_ValiDATE);     
              end if;
              end; What i want to do is to retieve not only the current record for the selected node but aslo the related childern in the tree to this node.
    Could anyboady help me pls. ?!
    Regards,
    Abdetu..

    Hi Tony,
    what i am trying to do is to display all childern related to the parent 's node selected from the tree that's works fine..
    But i want to display the related datablock selected to the child itself the following can't do that can u help me doing it pls...!
    DECLARE
         rank number := 0;
         HTREE$ ITEM := Find_Item('TREE_BLOCK_TEST.TREE13');
    BEGIN
    IF :SYSTEM.TRIGGER_NODE_SELECTED = 'TRUE' THEN
         rank :=     ftree.get_tree_node_property
         ('TREE_BLOCK_TEST.TREE13',:system.trigger_node, ftree.node_depth);
         if rank = 1 then
         set_block_property ('INSP_EQUIPMENT_TYPE', default_where
              , 'parent_id='||ftree.get_tree_node_property('TREE_BLOCK_TEST.TREE13',
              :system.trigger_node, ftree.node_value));
                        GO_BLOCK ('INSP_EQUIPMENT_TYPE');
                        Execute_Query(No_ValiDATE);     
         elsif rank > 1 then
              set_block_property ('INSP_EQUIPMENT_TYPE', default_where
              ,'EQUIPMENT_TYPE_D='||ftree.get_tree_node_property('TREE_BLOCK_TEST.TREE13',
              :system.trigger_node, ftree.node_value));
         else
         :INSP_EQUIPMENT_TYPE.EQUIPMENT_TYPE :=
    FTREE.GET_TREE_NODE_PROPERTY(HTREE$, :SYSTEM.TRIGGER_NODE, FTREE.NODE_LABEL);
         END IF;
         END IF;
         END;

  • Read Selected Tree Node value.  Jdeveloper Jdeveloper 11.1.2.1.0 11.1.2.1.0

    Version: Jdeveloper 11.1.2.1.0
    how to get programmatically tree node value.
    i have tried but cann't read value from selected node.
    please help me.
    here is my application creation steps:
    1. New Application
    2. Fusion Web Application (ADF) Template
    3. Create View Object VOTreeMst
    Query:
         Select Department_Name,Department_Id
         From Departments
    4. Create View Object VOTreeChd
    Query:
         Select Last_Name,Employee_Id,Department_Id
         From Employees
    5. Create View Link VLTreeMstChd
         VOTreeMst.DepartmentId=VOTreeChd.DepartmentId
         And Add to Application Module
    6. Create page page1 in ViewController
         New-->Web Tier-->JSF/Facelets-->Page
         Selected Document Type JSP XML
    7. Drag VOTreeMst1 From Data Controls into page1
    and select Tree-->ADF Tree
    8. ADD java Code into selection Listener
    public void nodeSelect(SelectionEvent selectionEvent) {
    //original selection listener set by ADF
    String adfSelectionListener = "#{bindings.VOTreeMst1.treeModel.makeCurrent}";
    //make sure the default selection listener functionality is preserved.
    //you don't need to do this for multi select trees as the ADF binding
    //only supports single current row selection
    /* START PRESERVER DEFAULT ADF SELECT BEHAVIOR */
    FacesContext fctx = FacesContext.getCurrentInstance();
    Application application = fctx.getApplication();
    ELContext elCtx = fctx.getELContext();
    ExpressionFactory exprFactory = application.getExpressionFactory();
    MethodExpression me = null;
    me = exprFactory.createMethodExpression(elCtx, adfSelectionListener, Object.class,
    new Class[] { SelectionEvent.class });
    me.invoke(elCtx, new Object[] { selectionEvent });
    /* END PRESERVER DEFAULT ADF SELECT BEHAVIOR */
    RichTree tree = (RichTree)selectionEvent.getSource();
    TreeModel model = (TreeModel)tree.getValue();
    //get selected nodes
    RowKeySet rowKeySet = selectionEvent.getAddedSet();
    Iterator rksIterator = rowKeySet.iterator();
    //for single select configurations, thi sonly is called once
    while (rksIterator.hasNext()) {
    List key = (List)rksIterator.next();
    JUCtrlHierBinding treeBinding = null;
    CollectionModel collectionModel = (CollectionModel)tree.getValue();
    treeBinding = (JUCtrlHierBinding)collectionModel.getWrappedData();
    JUCtrlHierNodeBinding nodeBinding = treeBinding.findNodeByKeyPath(key);
    Row rw = nodeBinding.getRow();
    //print first row attribute. Note that in a tree you have to determine the node
    //type if you want to select node attributes by name and not index
    String rowType = rw.getStructureDef().getDefName();
    if(rowType.equalsIgnoreCase("VOTreeMst")){
    System.out.println("This row is a department: " + rw.getAttribute("DepartmentId"));
    else if(rowType.equalsIgnoreCase("VOTreeChd")){
    System.out.println("This row is an employee: " + rw.getAttribute("EmployeeId"));
    else{
    System.out.println("Huh ????");
    // ... do more usefuls stuff here
    9. when i click on first node it is working but i click on second node it is not working
    error message::
    <LifecycleImpl> <_handleException> ADF_FACES-60098:Faces lifecycle receives unhandled exceptions in phase INVOKE_APPLICATION 5
    javax.el.ELException: java.lang.NullPointerException
         at com.sun.el.parser.AstValue.invoke(Unknown Source)
         at com.sun.el.MethodExpressionImpl.invoke(Unknown Source)
         at org.apache.myfaces.trinidad.component.UIXComponentBase.broadcastToMethodExpression(UIXComponentBase.java:1589)
         at org.apache.myfaces.trinidad.component.UIXTree.broadcast(UIXTree.java:237)
    <RegistrationConfigurator> <handleError> ADF_FACES-60096:Server Exception during PPR, #1
    javax.el.ELException: java.lang.NullPointerException
    I have also tried using following code but same problem
    public void onTreeSelect(SelectionEvent selectionEvent) {
    //original selection listener set by ADF
    String adfSelectionListener = "#{bindings.VOTreeMst1.treeModel.makeCurrent}";
    //make sure the default selection listener functionality is preserved.
    //you don't need to do this for multi select trees as the ADF binding
    //only supports single current row selection
    /* START PRESERVER DEFAULT ADF SELECT BEHAVIOR */
    FacesContext fctx = FacesContext.getCurrentInstance();
    Application application = fctx.getApplication();
    ELContext elCtx = fctx.getELContext();
    ExpressionFactory exprFactory = application.getExpressionFactory();
    MethodExpression me = null;
    me = exprFactory.createMethodExpression(elCtx, adfSelectionListener, Object.class,
    new Class[] { SelectionEvent.class });
    me.invoke(elCtx, new Object[] { selectionEvent });
    /* END PRESERVER DEFAULT ADF SELECT BEHAVIOR */
    RichTree tree = (RichTree)selectionEvent.getSource();
    TreeModel model = (TreeModel)tree.getValue();
    //get selected nodes
    RowKeySet rowKeySet = selectionEvent.getAddedSet();
    Iterator rksIterator = rowKeySet.iterator();
    //for single select configurations, thi sonly is called once
    while (rksIterator.hasNext()) {
    List key = (List)rksIterator.next();
    JUCtrlHierBinding treeBinding = null;
    treeBinding = (JUCtrlHierBinding)((CollectionModel)tree.getValue()).getWrappedData();
    JUCtrlHierNodeBinding nodeBinding = treeBinding.findNodeByKeyPath(key);
    Row rw = nodeBinding.getRow();
    //print first row attribute. Note that in a tree you have to determine the node
    //type if you want to select node attributes by name and not index
    System.out.println("row: " + rw.getAttribute(0));
    But
    If i create .jspx page From
    Web Tier->Jsp->page Then it is working fine
    when i create .jspx page From
    Web Tier->JSF\Facelets->page Then it is not working
    i need to get value from "Web Tier->JSF\Facelets->page"
    is there any help please?

    You should try Franks generic selectionListener http://www.oracle.com/technetwork/developer-tools/adf/learnmore/25-generic-tree-selection-listener-169164.pdf. For help on hoe to get the selected tree node data check http://www.oracle.com/technetwork/developer-tools/adf/learnmore/26-get-selected-tree-node-data-169165.pdf
    Timo

  • Error in Getting Selected Tree node From POPUPMENU

    Environment: Forms 9i, 9i AS
    The Folowing code is written with in POPUP MENU to get the selected tree node. It always returns 0. The samE code works fine with in any other TRIGGER. Is it Forms BUG?
    v_sel_tree := ftree.GET_TREE_SELECTION(v_item,1);

    Whether or not it is a bug you need a workaround.
    How about getting the when-tree-node-selected to set a package variable and look at its value in the pop-up menu code.

  • Value of currently selected tree node

    Hi there,
    I'm new to Apex(4.1.1) and i'm having a little problem.
    I got 2 Pages. The frist one consists of a treeregion and a submit button.
    The Second one is a Report.
    I want to create a workflow, that the user selects a treenode and presses submit. Then he'll be redirected to the reportspage,
    wich will show him a report depending on the treenode he selected on the first Page.
    Problem:
    I have no idea how i can read the value of the selected treenode.
    I hope you can help me.
    thanks,
    Frederic

    Hi Frederic,
    To obtain the value of the selected tree node, you can make use of the "Selected Page Node Item" attribute on the Tree Attributes page. Just create an item on your page, and set the "Selected Page Node Item" to that new page item. Then populate that item via the LINK parameter of your tree query. For an example, take a look at the following: http://apex.oracle.com/pls/apex/f?p=36648:6 , where I'm setting my page item P6_SELECTED_NODE to the value of the node selected on the first tree i.e. empno. Your report query would need to reference the "Selected Page Node Item", to ensure that it displays information related to the selected tree node.
    I hope this helps.
    Regards,
    Hilary

  • ADF Tree 10.1.3.1, not highlighting the selected node.

    Hi,
    I'm having a problem highlighting the selected node in the ADF CoreTree.
    I use the treehandler and model as described in the link: http://technology.amis.nl/blog/2116/much-faster-adf-faces-tree-using-a-pojo-as-cache-based-on-read-only-view-object-showing-proper-leaf-nodes-again
    I use this objects because my tree was showing leaf node with the image to collapse.
    The tree now looks great, the only problem is that when i click on a node the focusRowKey is set accordingly(debugging the getter and setter) but is not show as the selected node.
    The tree jspx code looks the follow:
                   <!--TREE-->
                                     <af:tree value="#{ActosTreeHandler.treemodel}" var="node"
                                               focusRowKey="#{ActosTreeHandler.focusRowKey}"
                                               id="treeActos"
                                               varStatus="nodeStatus" binding="#{ActosTreeHandler.jsfTree}">
                                        <f:facet name="nodeStamp">
                                          <af:commandLink text="#{node.description}" partialTriggers="treeActos"
                                                          action="#{backing_documentos_detalhesDocumento.treeAction}">
                                            <!--disabled="#{node.nodeType != 'ACTO'}"-->
                                            <af:setActionListener from="#{ActosTreeHandler.jsfTree.rowKey}"
                                                                  to="#{ActosTreeHandler.focusRowKey}"/>
                                            <af:setActionListener from="#{node}"
                                                                  to="#{ActosTreeHandler.selectedNode}"/>
                                            <af:resetActionListener/>
                                          </af:commandLink>
                                        </f:facet>
                                      </af:tree>Does anyone know how this can be solved?
    Best Regards.

    Hi,
    is this the same as
    Re: Facing a problem in programmatically setting focus on a node in <af:tre
    Frank

  • Select tree node in tree component

    hi,
    i am developing a web site which has a site map as a tree component, the sitemap is a inserted in a page fragment, users could click tree nodes to go to corresponding pages. also on other pages, i have next and previous buttons which allow users to navigate through pages. the question is how can i update the tree component when users navigate using the next and previous buttons so that the correct tree node is highlighted?
    i tried to use the selected property for the tree component, but it does not do anything.
    thanks,
    lee

    Hi,
    Duplicate thread of
    http://swforum.sun.com/jive/thread.jspa?threadID=64518
    MJ

  • Highlight an ADF tree node when it is clicked

    Hello every onei ,
    Does anybody has any idea how to highlight an ADF tree node when it is clicked ?
    Here is my scenario:-
    I have a popup which has a tree component on left and when we click on any node in the tree we have to display the corresponding page on right side.
    As the tree is common for all pages in the popup, i created an XHTML template with tree. All the treenode pages will use this template to display the tree.This template i am using to implement in rest of the pages.
    So when i click any link on this tree will load the corresponding JSP. But i am loosing focus. i mean selected node is not highlighting. Because we are loading the entire target page with template.
    Could any let me know how to highlight the tree node ?
    The Main problem is we are not using ADF controllers. We are using managed beans, these managed beans attached to the JSPX pages.
    Kindly guide me if any one knows solution.
    Thanks & Regards,
    Sai Sravan.P

    Hello Sai,
    I am afraid you have posted your question in the wrong forum. This forum is about Oracle On Track Communication, a next-generation social enterprise collaboration product.
    Please re-post your question in an ADF related forum and I am sure someone will be able to answer.
    Thank you,
    Ernst.

  • Assigning Selected Tree Node Value To An Item

    Hi guys,
    I want to assign selected tree node's value to a page item. This item can be a textbox or a label (display only). How can i do that? I tried to use "Selected Node Page Item" property which is available on Tree Attributes. But I couldn't assign the value without refreshing whole page.
    Do you have any idea?
    Thanks.

    Hi ,
    Thank you that was exactly what I was looking for. I couldn't find how to pass database column to javascript as an input parameter. So thanks for your help. I made a couple of correction :
    1) I put additional ' characters to ('''||"NAME"||''') this part because my field is varchar.
    select case when connect_by_isleaf = 1 then 0
    when level = 1 then 1
    else -1
    end as status,
    level,
    NAME as title,
    null as icon,
    "ID" as value,
    null as tooltip,
    'javascript:setFObjName('''||"NAME"||''')' As link
    from "#OWNER#"."TABLE_NAME"
    start with "PID" is null
    connect by prior "ID" = "PID"
    2) In script I have added ' character before and after page item.
    function setFObjName(pobjName){
    $s('P1_OBJ_NAME', pobjName);
    So it works. Thanks tfor your help.

  • How to highlight the selected value in a table

    Hi All,
    I have list of roles in a table like admin,dba...etc.
    i will select the current selected role using
      Stgin role =wdCotext.currentElement().getRole();
    After getting the role i bind this value in context.
    now my requiremnet is i will navigate to other table view containing all roles like admin,dba,networkadmin .
    I have to highlight the selected role in previous table to new table containing the  all the roles.
    means selected role should be highlight in a next table view list of roles.
    please help.

    Hi mohammad,
    To achieve this functionality, use another integer variable to store the index of the currently selected element in the first view. Pass this variable's value to the next view (either as plug parameter or throgh mapping) and set the Lead selection for the table as this index in the second view.
    In the first View ....
    int n = wdContext.current<your_node>Element().index()
    pass this value from first view to second view.
    In the second view
    wdContext.node<your_node>().setLeadSelection(n)
    Hope this helps,
    Best Regards,
    Nibu.
    Message was edited by: Nibu Wilson

  • Clicking on TOC Item Jumps to Previous Identical Entry. How to highlight the selected one?

    Win 7, 64 bit
    RH 9 (latest patch)
    HtmlHelp (CHM) output
    I have many TOC pages that are identical.
    For example, in our software some toolbar icons are repeated on different screens. In the built CHM help, if I click on a later identical page reference in our TOC, the TOC automatically jumps focus to the first entry. It doesn't stay on the selected entry.
    This causes confusion as all of a sudden the user is in an entirely different context. How can I get it to highlight the selected item and not jump to the first reference?

    Hi Jared
    Note that this issue is generically related to any help system and isn't a "RoboHelp specific thing". When multiple points in a Table of Contents reference the same page, how is the system supposed to determine exactly which TOC node is the correct one?
    The way past this is to create multiple distinct nodes from the TOC to the topic.
    One way involves never creating an actual link from the TOC to the topic. Instead, create as many distinct topics as you need in the TOC and have them redirect to the desired topic. The bottom line is that the correct page is presented and the correct TOC node is highlighted.
    Another way involves a similar approach. Create distinct topics that simply present an inline frame (IFRAME) that has the single "real" topic.
    Yet another way involves another variation. Create a Snippet that is essentially the single entire topic. Then create distinct topics that only contain the snippet.
    Hope this helps... Rick
    Helpful and Handy Links
    RoboHelp Wish Form/Bug Reporting Form
    Begin learning RoboHelp HTML 7, 8 or 9 within the day!
    Adobe Certified RoboHelp HTML Training
    SorcerStone Blog
    RoboHelp eBooks

  • CTE for Count the Binary Tree nodes

    i have the table structure like this :
    Create table #table(advId int identity(1,1),name nvarchar(100),Mode nvarchar(5),ReferId int )
    insert into #table(name,Mode,ReferId)values('King','L',0)
    insert into #table(name,Mode,ReferId)values('Fisher','L',1)
    insert into #table(name,Mode,ReferId)values('Manasa','R',1)
    insert into #table(name,Mode,ReferId)values('Deekshit','L',2)
    insert into #table(name,Mode,ReferId)values('Sujai','R',2)
    insert into #table(name,Mode,ReferId)values('Fedric','L',3)
    insert into #table(name,Mode,ReferId)values('Bruce','R',3)
    insert into #table(name,Mode,ReferId)values('paul','L',4)
    insert into #table(name,Mode,ReferId)values('walker','R',4)
    insert into #table(name,Mode,ReferId)values('Diesel','L',5)
    insert into #table(name,Mode,ReferId)values('Jas','R',5)
    insert into #table(name,Mode,ReferId)values('Edward','L',6)
    insert into #table(name,Mode,ReferId)values('Lara','R',6)
    select *from #table
    How do i write the CTE for count the Binary tree nodes on level basis. Here is the example,
    now,what i want to do is if i'm going to calculate the Count of the downline nodes.which means i want to calculate for '1' so the resultset which i'm expecting
    count level mode
    1 1 L
    1 1 R
    2 2 L
    2 2 R
    4 3 L
    2 3 R
    How do i acheive this,i have tried this
    with cte (advId,ReferId,mode,Level)
    as
    select advId,ReferId,mode,0 as Level from #table where advid=1
    union all
    select a.advId,a.ReferId,a.mode ,Level+1 from #table as a inner join cte as b on b.advId=a.referId
    select *From cte order by Level
    i hope its clear. Thank you

    See Itzik Ben-Gan examples for the subject
    REATE TABLE Employees
      empid   int         NOT NULL,
      mgrid   int         NULL,
      empname varchar(25) NOT NULL,
      salary  money       NOT NULL,
      CONSTRAINT PK_Employees PRIMARY KEY(empid),
      CONSTRAINT FK_Employees_mgrid_empid
        FOREIGN KEY(mgrid)
        REFERENCES Employees(empid)
    CREATE INDEX idx_nci_mgrid ON Employees(mgrid)
    SET NOCOUNT ON
    INSERT INTO Employees VALUES(1 , NULL, 'Nancy'   , $10000.00)
    INSERT INTO Employees VALUES(2 , 1   , 'Andrew'  , $5000.00)
    INSERT INTO Employees VALUES(3 , 1   , 'Janet'   , $5000.00)
    INSERT INTO Employees VALUES(4 , 1   , 'Margaret', $5000.00) 
    INSERT INTO Employees VALUES(5 , 2   , 'Steven'  , $2500.00)
    INSERT INTO Employees VALUES(6 , 2   , 'Michael' , $2500.00)
    INSERT INTO Employees VALUES(7 , 3   , 'Robert'  , $2500.00)
    INSERT INTO Employees VALUES(8 , 3   , 'Laura'   , $2500.00)
    INSERT INTO Employees VALUES(9 , 3   , 'Ann'     , $2500.00)
    INSERT INTO Employees VALUES(10, 4   , 'Ina'     , $2500.00)
    INSERT INTO Employees VALUES(11, 7   , 'David'   , $2000.00)
    INSERT INTO Employees VALUES(12, 7   , 'Ron'     , $2000.00)
    INSERT INTO Employees VALUES(13, 7   , 'Dan'     , $2000.00)
    INSERT INTO Employees VALUES(14, 11  , 'James'   , $1500.00)
    The first request is probably the most common one:
     returning an employee (for example, Robert whose empid=7) 
    and his/her subordinates in all levels. 
    The following CTE provides a solution to this request:
    WITH EmpCTE(empid, empname, mgrid, lvl)
    AS
      -- Anchor Member (AM)
      SELECT empid, empname, mgrid, 0
      FROM Employees
      WHERE empid = 7
      UNION ALL
      -- Recursive Member (RM)
      SELECT E.empid, E.empname, E.mgrid, M.lvl+1
      FROM Employees AS E
        JOIN EmpCTE AS M
          ON E.mgrid = M.empid
    SELECT * FROM EmpCTE
    Using this level counter you can limit the number of iterations
     in the recursion. For example, the following CTE is used to return 
    all employees who are two levels below Janet:
    WITH EmpCTEJanet(empid, empname, mgrid, lvl)
    AS
      SELECT empid, empname, mgrid, 0
      FROM Employees
      WHERE empid = 3
      UNION ALL
      SELECT E.empid, E.empname, E.mgrid, M.lvl+1
      FROM Employees as E
        JOIN EmpCTEJanet as M
          ON E.mgrid = M.empid
      WHERE lvl < 2
    SELECT empid, empname
    FROM EmpCTEJanet
    WHERE lvl = 2
    As mentioned earlier, CTEs can refer to
     local variables that are defined within the same batch.
     For example, to make the query more generic, you can use 
    variables instead of constants for employee ID and level:
    DECLARE @empid AS INT, @lvl AS INT
    SET @empid = 3 -- Janet
    SET @lvl   = 2 -- two levels
    WITH EmpCTE(empid, empname, mgrid, lvl)
    AS
      SELECT empid, empname, mgrid, 0
      FROM Employees
      WHERE empid = @empid
      UNION ALL
      SELECT E.empid, E.empname, E.mgrid, M.lvl+1
      FROM Employees as E
        JOIN EmpCTE as M
          ON E.mgrid = M.empid
      WHERE lvl < @lvl
    SELECT empid, empname
    FROM EmpCTE
    WHERE lvl = @lvl
    Results generated thus far might be returned (but are not guaranteed to be), 
    and error 530 is generated. You might think of using the MAXRECURSION option 
    to implement the request to return employees who are two levels below 
    Janet using the MAXRECURSION hint instead of the filter in the recursive member
    WITH EmpCTE(empid, empname, mgrid, lvl)
    AS
      SELECT empid, empname, mgrid, 0
      FROM Employees
      WHERE empid = 1
      UNION ALL
      SELECT E.empid, E.empname, E.mgrid, M.lvl+1
      FROM Employees as E
        JOIN EmpCTE as M
          ON E.mgrid = M.empid
    SELECT * FROM EmpCTE
    OPTION (MAXRECURSION 2)
    WITH EmpCTE(empid, empname, mgrid, lvl, sortcol)
    AS
      SELECT empid, empname, mgrid, 0,
        CAST(empid AS VARBINARY(900))
      FROM Employees
      WHERE empid = 1
      UNION ALL
      SELECT E.empid, E.empname, E.mgrid, M.lvl+1,
        CAST(sortcol + CAST(E.empid AS BINARY(4)) AS VARBINARY(900))
      FROM Employees AS E
        JOIN EmpCTE AS M
          ON E.mgrid = M.empid
    SELECT
      REPLICATE(' | ', lvl)
        + '(' + (CAST(empid AS VARCHAR(10))) + ') '
        + empname AS empname
    FROM EmpCTE
    ORDER BY sortcol
    (1) Nancy
     | (2) Andrew
     |  | (5) Steven
     |  | (6) Michael
     | (3) Janet
     |  | (7) Robert
     |  |  | (11) David
     |  |  |  | (14) James
     |  |  | (12) Ron
     |  |  | (13) Dan
     |  | (8) Laura
     |  | (9) Ann
     | (4) Margaret
     |  | (10) Ina
    Best Regards,Uri Dimant SQL Server MVP,
    http://sqlblog.com/blogs/uri_dimant/
    MS SQL optimization: MS SQL Development and Optimization
    MS SQL Consulting:
    Large scale of database and data cleansing
    Remote DBA Services:
    Improves MS SQL Database Performance
    SQL Server Integration Services:
    Business Intelligence

  • Adding image for the selected Tree leaf???

    Hi All,
             I am working with flex tree component in which i have to add
    an arrow image for the  selected leaf node. I tried to do this using itemclick event
    but cant make it. can you help me out in doing this???
    Note: I have written custom Tree and TreeItemRenderer...
    -Sundar

    Thanks for ur reply Grizzzzzzzzz,
                                                    is there a way to identify the selected leaf from within MyTreeItemRenderer(Extends TreeItemRenderer)?
                                                   If this is possible,i can add the image to the selected leaf of the tree.
    Right now i am assigning images to all the leaf nodes of the tree as follows:
    public  
    class MyTreeItemRenderer extends TreeItemRenderer
    * Override to draw a line in case current item is a leaf.
     override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):
    void{ 
    // Call super method 
    super.updateDisplayList(unscaledWidth, unscaledHeight);
    if(super.data){
    if(TreeListData(super.listData).hasChildren){
    // logic for parent node comes here
    else{ 
    //Adding leaf Image
    //Logic to add images to leaf 
    myImage.source = leafImage;
    myImage.x =
    super.label.x;
    //The above code adds images to all leaf nodes. CAN I ADD THIS IMAGE ONLY TO THE SELECTED LEAF NODE???
    //HOW TO FIND THE SELECTED LEAF NODE FROM HERE??? SO THAT SELECTED LEAF WILL BE ADDED WITH THE IMAGE???
    //The above code adds images to all leaf nodes. CAN I ADD THIS IMAGE ONLY TO THE SELECTED LEAF NODE???
    //HOW TO FIND THE SELECTED LEAF NODE FROM HERE??? SO THAT SELECTED LEAF WILL BE ADDED WITH THE IMAGE???
    THANKS,
    SUNDAR 

Maybe you are looking for

  • Ipod First gen connetivity problem

    I've just got given a first generation ipod from a friend but i'm having problems connecting to windows. I have another first gen which is working fine on my pc! come to life as soon as it is plugged into the firewire card at the back of the pc and u

  • Bbm problem

    i have a problem with my bbm, everytime i try send a bbm a red x comes up, does anyone know what this means??

  • Editor panel has disappeared in Organizer window.

    I can no longer access the Editor panel in my Organizer window or any other options that were there?  Any idea how to get it back?

  • Photoshop Elements 9 Out of Bounds Tut

    I need help creating a layout with Out of Bonds with creating my own templet please. I am up to the point of placing it in my layout, but am lost after this. Thanks, Charlene

  • Adobe on mac air 1.4 gHz

    I just recently bought a MacBook Air and i have tried to install adobe flash player and reader on it and even after installing java and enabling the plugins it starts the installation and then stops at 30%. I have also tried quit Safari and other bas