PDA

View Full Version : disable/enable treenode



psourisseau2
12 May 2015, 8:08 AM
Hi,
I would like to enable or disable treenode on a checkable tree.
I cans disable check with addBeforeCheckChangeHandler implementation but i should like to change the appearance for the disabled nodes.


I try this without result :
XElement theElement = this.getView().getElement(theNode) ;
// ---
if( enabled ) {
theElement.enable() ;
theElement.removeClassName("disabled");
}
else {
theElement.disable() ;
theElement.addClassName("disabled");
}


and in css file for example :
.disabled {
text-decoration: underline ;
color : red ;
}

What's wrong or missing ?
Thx for your help
Regards,
Pascal

Andreas Samjeske
13 May 2015, 12:20 AM
Hi Pascal,
welcome to the forum. If you write code here please put it in code tags [ code ] *yourCodeHere* [ /code ] (without spaces). That way it'll be much easier to read.

To your problem:
1.) When does your code run, i.e. where did you put it?
2.) "without result" is not a good error description. I guess you have more info. Tell us.
3.) What else did you try? Debugging? Searching for "disabled" (bad word for searching) by Firebug?

psourisseau2
13 May 2015, 1:45 AM
Hi,
I solve it .... i use getView().getElement(theNode) instead of getView().getElementContainer( theNode)

Thx
Best regards
Pascal

Andreas Samjeske
13 May 2015, 1:50 AM
Hi,
I solve it .... i use getView().getElement(theNode) instead of getView().getElementContainer( theNode)

Thx
Best regards
Pascal

I am confused. You mentioned getElement not getElementContainer in your first post.
I assume the code above was already the fixed version?!

psourisseau2
14 May 2015, 8:59 AM
I am confused. You mentioned getElement not getElementContainer in your first post.
I assume the code above was already the fixed version?!

Andreas,
Excuse me, this piece of code works fine : i use getElementContainer for solving node classname modification


// not work
// XElement theElement = this.getView().getElement(theNode) ;
// work
XElement theElement = this.getView().getElementContainer(theNode) ;
// ---
if( enabled ) {
theElement.enable() ;
theElement.removeClassName("disabled");
}
else {
theElement.disable() ;
theElement.addClassName("disabled");
}

Best regards
Pascal