views:

557

answers:

1

I have a tree with nodes that contain tasks.

Completed tasks have attribute status: 100 and class cls: "done".

I would like to make a button for hiding completed tasks.

What function will hide nodes in a tree by their id or class?

{"id":"45",
"description":"Pay bills",
"status":"100",
"cls":"done",
"uiProvider":"col",
"leaf":true}
+2  A: 

Try walking the tree starting at the root and testing for the attribute(s) you want. If you get a hit, hide the node:

tree.getRootNode().cascade(function() { // descends into child nodes
    if(this.attributes['status'] == 100) { // test this node
        this.getUI().hide() // hide this node
    }
})

You actually asked about testing by the class "done". In that case just test if this.attributes['cls'] == 'done' instead. I prefer checking "status" than "cls" as the latter can be space-separated and messy.

Roatin Marth
It works, Thanks!
Alex L