primeng icon indicating copy to clipboard operation
primeng copied to clipboard

How to avoid setting styleClass of children when applying styleClass of a TreeNode

Open pdhamija opened this issue 9 years ago • 5 comments

How to avoid setting styleClass of children when applying styleClass of a TreeNode?

Part of the tree node structure looks like this --

					"label": "My parent Node",
					"data": {
						"id": 145336,
					},
					"expandedIcon": "fa-minus-square",
					"collapsedIcon": "fa-plus-square",
					"icon": null,
					"leaf": false,
					"droppable": null,
					"draggable": null,
					"expanded": true,
					"*styleClass": "movedNodeClass",
					"children": [{
						"label": "My Child Node-1",
						"data": {
							"id": 3025,
						},
						"expandedIcon": null,
						"collapsedIcon": null,
						"icon": "fa-leaf",
						"leaf": true,
						"droppable": null,
						"draggable": null,
						"expanded": null,
						"styleClass": null,
						"children": [],
						"parent": null
					}, {
						"label": "My Child Node-2",
						"data": {
							"id": 3030,
						},
						"expandedIcon": null,
						"collapsedIcon": null,
						"icon": "fa-leaf",
						"leaf": true,
						"droppable": null,
						"draggable": null,
						"expanded": null,
						"styleClass": null,
						"children": [],
						"parent": null
					}],
					"parent": null
				}],
				"parent": null
			},

Current behavior The parent node has styleclass set as "movedNodeClass", which looks like

.movedNodeClass .ui-treenode-content { background-color: coral; color: black; }

Notice that 2 children have styleclass set as null. But still, the styleclass of parent, gets applied to both the children. How to avoid that? I want the styleclass applied just to parent, not the child.

Note: the setting of encapsulation is - encapsulation: ViewEncapsulation.None

Expected behavior I want the styleclass applied just to parent, not the child.

pdhamija avatar Nov 07 '17 18:11 pdhamija

.movedNodeClass > .ui-treenode-content {
    background-color: coral;
    color: black;
}

cagataycivici avatar Nov 17 '17 10:11 cagataycivici

@cagataycivici that didn't fix anything. In fact, I lost the styles on all nodes. Issue still not resolved. Would appreciate if you/anyone has any suggestions. Thanks.

pdhamija avatar Nov 17 '17 18:11 pdhamija

Any resolution on this? This behavior is causing issues for me as well.

l2018ng avatar May 23 '18 20:05 l2018ng

Hi, I'm stuck at the exact same problem. Does anyone have a solution to this?

codeharshit avatar May 19 '21 14:05 codeharshit

I have the issue that styleClass is not applying at all, nor to parents.

angelasrc93 avatar Jun 07 '24 09:06 angelasrc93