disable expand icon and labeledit

14 posts, 0 answers
  1. Jorge Delgado-Lopez
    Jorge Delgado-Lopez avatar
    82 posts
    Member since:
    Aug 2007

    Posted 27 Jun 2007 Link to this post

    Hi,

    Thank you for your fabulous support.

    For some nodes in a tree I need to disable to ability to change the label (LabelEdit on nodes?). I thought that IsLabelEdit would do it, but it is a status for when its happening I suppose since it is readonly. I had to use the event BeforeLabelEdit on the tree, check the node and do canceledit which works fine, but it would be nice to do it on the node level (I inherit from RadTreeNode and handle all functionality of the node in that class), so what I am asking for is to maybe add something like AllowLabelEdit to the node, a nice to have but not essential.

    I need to hide the expand icon on some nodes, this I dont know how to do. Is it possible?

    Thanks,
    - jorge
  2. Todd Anglin
    Todd Anglin avatar
    2040 posts
    Member since:
    Aug 2005

    Posted 27 Jun 2007 Link to this post

    Jorge-

    With regards to expand/collapse icon, if a node has no child nodes it will not display the icon. That means you could clear the nodes collection for specific nodes that you do not want to expand and the expand icon will go away. Perhaps a future version of the TreeView can add a property for disabling the expand directly.

    Let me know if that helps.

    Thanks~
    Todd
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Jorge Delgado-Lopez
    Jorge Delgado-Lopez avatar
    82 posts
    Member since:
    Aug 2007

    Posted 27 Jun 2007 Link to this post

    Hm...

    "if a node has no child nodes it will not display the icon.". Not in my setup.

    I think I may have miswritten. What I would like is to set a node not to show the icon of expand, to show that it is a leaf. In my setup all nodes have the expand icon, and I would like some not to show it. Should play a little with the styles, maybe?

    Oh and about the change of the label, I keep getting weird results on where the textbox is shown, sometimes 2 nodes down, but I havent researched that one yet.

    Thanks Todd,
    - jorge
  5. Jordan
    Admin
    Jordan avatar
    547 posts

    Posted 28 Jun 2007 Link to this post

    Hi Jorge,

    Thank you for your suggestion. We will consider adding a AllowEdit property to RadTreeNode.

    Regarding the expanded image issue. You can remove the expanded image of a RadTreeNode by setting its StateImageIndex to -1 like:
     
    RadTreeNode node = this.radTreeView1.Nodes[0].Nodes["Search Folders"];  
    node.StateImageIndex = -1; 


    Regards,
    Jordan
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  6. Jorge Delgado-Lopez
    Jorge Delgado-Lopez avatar
    82 posts
    Member since:
    Aug 2007

    Posted 28 Jun 2007 Link to this post

    Jordan,

    Can't seem to get it to work. The expand image is still shown.

    Here is my code:

    RadTreeNode revivalPluginNode = new RadTreeNode(name);
    parentNode.Nodes.Add(revivalPluginNode);
    revivalPluginNode.StateImageIndex = -1;

    - jorge
  7. Jordan
    Admin
    Jordan avatar
    547 posts

    Posted 29 Jun 2007 Link to this post

    Hello Jorge,

    Seems we'll need more information on your exact scenario, as we tested the code again, and all went fine. Could you share which version of RadControls for WinForms are you using? I did my tests with the latest available internal version.

    It will be best if you can send us a simple project that demonstrates the problem. Just open a support ticket and attach your project.

    Thank you in advance for your assistance.
     

    Kind regards,
    Jordan
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  8. Jorge Delgado-Lopez
    Jorge Delgado-Lopez avatar
    82 posts
    Member since:
    Aug 2007

    Posted 04 Jul 2007 Link to this post

    Hi,

    I have found that the problem was that I had LoadOnDemand=true on the radtreeview.

    But. I am now trying to set it at node level, that is LoadOnDemand. The only problem seems to be that I cannot implicitly tell the branches that they are branches and the leafs that they are leafs.

    Other concerns: when editing a label the textbox is all over the place and the drag/drop doesnt seem to hit the right node. Known issues to be fixed for SP2?

    Thanks,
    / jorge

    I wrote something to illustrate with RadTreeView.LoadOnDemand = false;

        public class Branch : RadTreeNode {
            private Branch parent = null;

            public Branch(Branch parent, string name) {
                this.Name = name;
                this.LoadedOnDemand = true;
                if (parent != null) {
                    this.parent = parent;
                    parent.Nodes.Add(this);
                }
            }

            public override void Expand() {
                new Leaf(this, "leaf");
                base.Expand();
            }
        }

        public class Leaf : RadTreeNode {
            private Branch parent = null;

            public Leaf(Branch parent, string name) {
                this.Name = name;
                this.LoadedOnDemand = false;
                if (parent != null) {
                    this.parent = parent;
                    parent.Nodes.Add(this);
                }
            }
        }
  9. Jordan
    Admin
    Jordan avatar
    547 posts

    Posted 05 Jul 2007 Link to this post

    Hello Jorge,

    Your code seems OK. But I'm not sure that I understand what you want to achieve by "implicitly telling the branches that they are branches and the leafs that they are leafs". Please clarify. By definition a node is a leaf, if it has no children.

    Regarding the other issues you mention, we are not sure what exactly you are experiencing. By default, the treeview offers visual indication where a node will be dropped, and you should not see any other behavior. We did not understand this line either: "the textbox is all over the place". Could you send us some screenshots of the problems you observe? We will also appreciate to see your exact implementation so that we find where the problem is. Just open a new support ticket and attach the files there. That way  we will be able to  identify the issues and tell you if they are fixed.

    As to SP2, RadTreeView has been significantly enhanced for ease of use. I am sure that you will find it improved and better.

    Thank you again for your assistance.
     

    Kind regards,
    Jordan
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  10. Jorge Delgado-Lopez
    Jorge Delgado-Lopez avatar
    82 posts
    Member since:
    Aug 2007

    Posted 05 Jul 2007 Link to this post

    Hi,

    I will try to clarify.

    a) The functionality I am looking for by "telling the branches that they are branches and the leafs that they are leafs" is to show/hide the expand icon as I see fit. To "AlwaysShowExpandIcon" on nodes I know will have children, and in certain Nodes never to show the expand icon since I know they do not and will never have children. In other words the expand icon (+/-) should be visible even if a node hasnt been expanded, but I should be able to disable this functionality in other cases. Say we have a tree with two root nodes in which one has the ability to have children (but hasnt been expanded and the Nodes property is empty at the moment) and the other one doesnt.

    + HasChildren
       HasNotChildren

    b) I cannot seem to reproduce these issues with the Q1SP2 I am running, they seems to have been fixed. Then again I had played with the themes, and now  those problems have disappeared after a complete reinstall of my developer machine.

    c) A new question: how do I find out the target node on a drag and drop operation? On DragEnded(RadTreeViewEventArgs) as well as DragEnding(RadTreeViewCancelEventArgs) the Node property is the "drag node".

    Thanks,
    / jorge

  11. Todd Anglin
    Todd Anglin avatar
    2040 posts
    Member since:
    Aug 2005

    Posted 05 Jul 2007 Link to this post

    EDIT: Apologies Jorge. I lost track of where I was and thought we were discussing the ASP.NET TreeView in this post. You challenges make more sense in the light of the WinForms controls. Sorry for the confusion~

    Jorge-

    Thanks for the extra details. I'm going to focus on your first question regarding the nodes for a moment.

    The behavior you've described seems to be exactly the behavior of the TreeView by default. If a node has no children, the +/- button does not get displayed. If it does have children, it does. If you do not want the children to be rendered at one time, set LoadOnDemand to True and the TreeView will automatically display the +/- to load child nodes if they exist (otherwise, the +/- won't be displayed).

    That said, I understand that it sounds like you may need more exacting control over the display the +/- buttons. I just want to make sure that you don't have to do extra work if the functionality already exists in the control. Let me know if I'm missing the key difference in your scenario that requires your custom approach.

    Thanks~
    Todd
  12. Jorge Delgado-Lopez
    Jorge Delgado-Lopez avatar
    82 posts
    Member since:
    Aug 2007

    Posted 05 Jul 2007 Link to this post

    Thanks Todd.

    Getting there :-)

    If I have my tree LoadOnDemand = true; then all nodes show +/-. If LoadOnDemand = false; then I must double click to see if the node will load any children and thus show +/-.

    What I need is a way to say "this is a folder and could have children" and "this is a file which will not have any children ever". The folder always showing +/- and the file never showing +/-. And I am loading all the folders dynamically.

    I have 5-6 classes of nodes, Groups, Devices, Plugins (leaf), Actions, Steps (leaf), and so on and I want the user to know that there are some nodes that cant expand (double click has other functionality).

    But I think that it will be fine, I will preparse the tree, add a node with the Label = "Expanding..." and remove that one before populating it. In that way I will be able to show the expand icon on "folders" and not on "files", but it would have been nice not to have to do it that way.

    Thanks,
    / jorge

    PS. What about  the question c) how do I find out the target node on a drag and drop operation? On DragEnded(RadTreeViewEventArgs) as well as DragEnding(RadTreeViewCancelEventArgs) the Node property is the "drag node".
  13. Jordan
    Admin
    Jordan avatar
    547 posts

    Posted 06 Jul 2007 Link to this post

    Hello Jorge,

    If I understand you correctly, you want some nodes that have not been expanded to not have an expand/collapse button even if Load On Demand is enabled. I believe this will be possible in SP2 (due next week) by setting LoadedOnDemand to true for the leaf nodes (that you know will never have children).

    Currently only the dragged node is provided with the RadTreeViewEventArgs. You can easily find the target node by keeping track of the parent (node or tree view) in your custom nodes. In the handler of the DragEnded event of RadTreeView you can check if the parent has changed and you will have the target node (if any).
     

    Sincerely yours,
    Jordan
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  14. Jorge Delgado-Lopez
    Jorge Delgado-Lopez avatar
    82 posts
    Member since:
    Aug 2007

    Posted 06 Jul 2007 Link to this post

    Hi Todd,

    Thanks for the answer.

    On the new question about the target node. What If I want to cancel the drop on DragEnding with e.Cancel? Just think of the case if Folders and Files are shown on a tree and one would move a Folder to be a children of a File?

    I could save the "original parent" and on DragEnded check and make the original parent the new parent. But it seems a bit odd.

    Thanks,
    / jorge
  15. Jordan
    Admin
    Jordan avatar
    547 posts

    Posted 09 Jul 2007 Link to this post

    Hello Jorge,

    In the SP2 release you will be able to get the target node from the event arguments in the handler of the DragEnding and DragEnded events of RadTreeView.

    Thank you again for the suggestion.

    Greetings,
    Jordan
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
Back to Top
UI for WinForms is Visual Studio 2017 Ready