Treeview under Combox Box

2 posts, 0 answers
  1. Pankaj Nagpal
    Pankaj Nagpal avatar
    1 posts
    Member since:
    Jul 2008

    Posted 08 Jan 2009 Link to this post

    We are using treeview under the RadComboBox. Some nodes are disable in treeview. Now when user try to select disable node in treeview then we are not allowing user to select node and cancelling the event at client site using this  args.set_cancel(true) under this event OnClientNodeClicking.

    After that we like to keep displaying previous selected node text value in combobox text because new node selection is invalid due to disable node.

      Now our problem is that after the post back in first client site event combo box doesn't able to show valid selected node value it shows value of all node text. after that from 2nd client side event onwards it works properly and started showing only selected node value and igonring disable node value in combo box.

      Here is the code which we have writtren OnClientNodClicking.

     

     

     

    function nodeClicking1(sender, args)  

     

    var comboBox = $find("<%= RadComboBox2.ClientID %>");  

     

    var node = args.get_node();  

     

    var parentnode = node.get_parent();  

     

    var tree = comboBox.get_items().getItem(0).findControl("RadTreeView3"); 

     

    var selectedNode = tree.get_selectedNode(); 

     

     

     

    var selectedtext = selectedNode.get_text();

     

     

     

     

     

    if (parentnode != null && node.get_enabled())  

    {

     

     

    comboBox.set_text(node.get_text());

     

     

    comboBox.trackChanges();

    comboBox.get_items().getItem(0).set_value(node.get_text());

    comboBox.set_text(node.get_text());

    comboBox.commitChanges();

    comboBox.hideDropDown();

     

    }

     

     

     

     

    else

     

    {

            args.set_cancel(

    true);

     

         

     

     

         //keep showing previous enable node value and igoner disable node value

     

         

    comboBox.set_text(selectedtext);
         comboBox.trackChanges();
         comboBox.set_text(selectedtext);
          comboBox.commitChanges();
         comboBox.showDropDown();
     }

     

     

     

    }

     

     

  2. Yana
    Admin
    Yana avatar
    4795 posts

    Posted 09 Jan 2009 Link to this post

    Hello Pankaj,

    You should place the treeview in a div with onclick event like this:

    <ItemTemplate> 
       <div id="div1" onclick="StopPropagation(event);">  
           <telerik:RadTreeView runat="server" ID="RadTreeView1" OnClientNodeClicking="nodeClicking">  
    ... 

    and the code for StopPropagation function:

    function StopPropagation(e)  
    {  
       if(!e)  
       {  
           e = window.event;  
       }  
           e.cancelBubble = true;  

    Hope this helps.

    Best wishes,
    Yana
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Back to Top