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.


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.

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.


Hello,


thank you for reminding. The modification is really useful.


We will necessary include it into the next tree version.