p:tree clear checkbox tree

UI Components for JSF
Post Reply
iciclethief
Posts: 2
Joined: 31 Jul 2010, 15:30

01 Sep 2011, 10:17

Hi,

I've been using the excellent p:tree (v 3.0.M3) component with selectionmode set to checkbox. I need to provide a 'clear selection(s)' option which will remove all checked items (and any highlights) in the tree. I've done this but I just wanted to check that there's not a simpler way, as the code I have relies too much on the components internal workings.

Currently I have the following code:

Code: Select all

function unSelectAll(tree) {
    tree.jq.find('.ui-tree-checkbox-icon').each(function() {
        var node = $(this).parents('li:first');
        tree.toggleCheckbox(node, false);
        node.find('.ui-tree-node-content:first').removeClass('ui-state-highlight');
        tree.removeFromSelection(node);
        tree.collapseNode(node);
        tree.writeSelections();
        tree.fireNodeUnselectEvent(node);
    });
 }

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 61 guests