Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by n.darques on Feb 27, 2009 09:56
open dhtmlx forum
dhtmlxTree setItemStyle function is additive

API of dhtmlxTree povides this function :

dhtmlXTreeObject.prototype.setItemStyle=function(itemId,style_string){
var temp=this._globalIdStorageFind(itemId);
if (!temp) return 0;
if (!temp.span.style.cssText)
temp.span.setAttribute("style",temp.span.getAttribute("style")+"; "+style_string);
else
temp.span.style.cssText+=(";"+style_string);
}

Thing is, it is designed as an additive function as you can only add extra Css rules and not reset those rules.
Might modify this function to this :

dhtmlXTreeObject.prototype.setItemStyle=function(itemId,style_string,resetCss){
var resetCss= resetCss|| false;
var temp=this._globalIdStorageFind(itemId);
if (!temp) return 0;
if (!temp.span.style.cssText)
temp.span.setAttribute("style",temp.span.getAttribute("style")+"; "+style_string);
else
temp.span.style.cssText = resetCss? style_string : temp.span.style.cssText+";"+style_string;
}

Thus, function is still retro-compatible and have a new feature.
Answer posted by Alex (support) on Mar 02, 2009 08:28

Hello

Yes, setItemStyle add a new style to existent. This feature should be taken into consideration when you apply this method several times for the same node. 

Answer posted by ndarques on Jun 18, 2009 05:18
Hello guys,

Just a reminder that latest revision of the dhtmlxTree.js code I'm using (v.2.1 build 90226) doesn't include modification of the setItemStyle method.

Answer posted by Alex (support) on Jun 18, 2009 06:15

Hello, 

thank you for reminding. The modification is really useful.

We will necessary include it into the next tree version.