Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Extjs TreePanel: How can I hide nodes by class or attribute?

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}
like image 761
Alex L Avatar asked Dec 30 '25 19:12

Alex L


1 Answers

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.

like image 94
Roatin Marth Avatar answered Jan 02 '26 08:01

Roatin Marth



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!