Skip to content

Only checkboxes on child nodes

New Discussion
Patric
Patric asked on Oct 17, 2011 1:19 PM

Hello,

i use the WebDataTree with a WebHierarchicalDatasource and CheckBoxMode ‘BiState’. But i don’t want the checkboxes on the parent nodes (only the leafs in the tree are ‘checkable’). Is there any simple way to change the default behavior (may be a flag or a property ‘no_parent_checkboxes’) ?

Sign In to post a reply

Replies

  • 0
    [Infragistics] Nikola Genov
    [Infragistics] Nikola Genov answered on Jan 6, 2010 1:24 PM

    Hi,

    Unfortunatelly WebDataTree doesn't support this scenario at the moment. However you can submit a feature request for it.

  • 0
    [Infragistics] David Young
    [Infragistics] David Young answered on Jan 6, 2010 2:43 PM

    Hi Page,

    As Nikola said, this is not built in, but you can get around it with some client code in the initialize event.  What you will do is hide the checkboxes you do not wish to show in the initialize event.  You said that you did not want parent nodes to be checkable.  I do not know whether you mean root nodes or in general, so I'll give some generic code.

    function HideCheckbox(node)
            {
                var childCount = node.get_childrenCount();
                if (childCount != 0)
                {
                    var checkbox = node._get_checkBox();
                    var checkboxEl = node._get_checkBox().get_element();
                    if (!checkboxEl && node._get_expandCollapseElement()){
                        checkboxEl = node._get_expandCollapseElement().nextSibling;
                    }
                    if (checkboxEl)
                    {
                        checkboxEl.style.display = "none";
                    }
                }
                for (var x = 0; x < childCount; ++x)
                {
                    var child = node.get_childNode(x);
                    HideCheckbox(child);
                }
            }
       
            function init(tree, args) {
                var root = tree.getNode(0);
                while (root != null) {
                    HideCheckbox(root);
                    root = root.get_nextNode();
                }
            }

    This code will hide checkbox in all nodes that do have children.  If you want to just do the root nodes, move the code where the checkbox is hidden into the while loop of init and don't worry about child nodes.  I checked this code in IE 8, FF, Safari, Opera, and Chrome. One thing to note is that the checkboxes that are hidden could still be automatically checked if you do not set EnableAutoChecking (available in 9.2) to false.  If you need this true or have 9.1, and you don't want nodes without checkbox in the checked nodes collection, I suggest handling CheckBoxSelectionChanged client event and uncheck those nodes in that event if needed.  Let me know if you need help.

    Hopefully this will get you by in the meantime.  But I suggest submitting that feature request.

    regards,
    David Young

     

    • 0
      Patric
      Patric answered on Jan 11, 2010 1:24 PM

      Hello David,

      thank's for your fast answer and sory for my time delay to answer. Your code exactly solve my problem and work fine. From a performance view, i don't like to catch the Initialize-Event; but it seems to be the right place to change the display style.

      Some questions to your code:

       Do i need the variable 'checkbox' ? It's never used.

      Is the recursive code faster then an iterative version ( may be in a reverse fashion; i traverse the tree with no checkboxes, if the actual node got a childCount of 0, this is a leaf, so set the checkbox. If not go to the next node.)?

      Is there a way to use Node-Templating (but how to trigger a node and a leaf)?

      Again, thank's for your solution

      regards,

      Patric

       

    • 0
      Dale Witsken
      Dale Witsken answered on Oct 16, 2011 12:49 AM

      Hi,

      I have tried to get this to work in vb.net and no luck yet. Is this for a WebDataTree? I do not see some of the functions for it like "node._get_checkBox().get_element();" . Do you have a vb example? Thanks.

      • 0
        Patric
        Patric answered on Oct 17, 2011 9:01 AM

        Hello ???,

        the code is for the WebDataTree; but it's client side JavaScript Code. May be there are some similar functions in vb.net, but i use c#; so i don't know and have no vb example.

        Patric

    • 0
      Dale Witsken
      Dale Witsken answered on Oct 17, 2011 1:00 PM

      This was very helpful for me, although I need to hide all child checkboxes and show only the root node checkboxes. I am not well versed in javascript and tried to play around with it with no luck. Can you point me in the right direction? Thanks!  Dale

    • 0
      Dale Witsken
      Dale Witsken answered on Oct 17, 2011 1:19 PM

      I actually just figured it out. Sorry, no need to reply.

  • You must be logged in to reply to this topic.
Discussion created by
Favorites
Replies
Created On
Last Post
Discussion created by
Patric
Favorites
0
Replies
7
Created On
Oct 17, 2011
Last Post
14 years, 4 months ago

Suggested Discussions

Created by

Created on

Oct 17, 2011 1:19 PM

Last activity on

Feb 11, 2026 9:33 PM