Results 1 to 10 of 11

Thread: Add Checkbox for Selected TreeItem [com.extjs.gxt.ui.client.widget.tree.TreeItem]

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Sencha User
    Join Date
    Oct 2012
    Vote Rating

    Default Answered: Add Checkbox for Selected TreeItem [com.extjs.gxt.ui.client.widget.tree.TreeItem]

    Hi all,

    I tried to google but i was not able to find how to add a checkbox for a selected node in a tree.

    By making Tree.setCheckable(true); will show a checkbox for all the parent and child node, my requirement is to have check box for only those node whose status is satisfied,

    Thank you in Advance

  2. TreePanel.setChecked governs the ability to check items, as well as the actual firing of events and informing the dom to do the work. Its default implementation makes sure the default options (Leaf-only, node-only, or all) are followed with this code:

          if ((!leaf && checkNodes == CheckNodes.LEAF) || (leaf && checkNodes == CheckNodes.PARENT)) {
    Overriding this method and providing nearly the same functionality would be tricky, as there are a number of private variables - it could be done, but you'd need lots of JSNI to accomplish this.

    Instead, take a look at the events fired as part of this process. When a Before- event is fired, this gives listening code the chance to stop whatever is happening by invoking .setCanceled(true);

    How does this help you? There is a BeforeCheckChange event that goes off prior to actually checking the items - if you listen to this, you can customize the behavior of what is allowed to be checked. To make this work correctly, allow all nodes to be checked (using setCheckNodes), then implement your "can the user check this?" logic in your BeforeCheckChange listener.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts