Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by Abbie on Dec 14, 2009 18:41
open dhtmlx forum
DhtmlxTree update method

Hi,

I wish to update Text attributes of Items in my tree when certain condition applies. I'm using custom images for im0, im1 and im2 attributes of the Items. The code snippet looks like below:

if (tree.getLevel(nodeId) > 0 ) {
tree.updateItem(nodeId);
tree.setItemText(nodeId, 'newLabel');
tree.selectItem(nodeId, false);
}

However, when the tree was rendered following execution of above code, the custom images were changed to default images. How can the original images be preserved?

Thanks!
Answer posted by Alex (support) on Dec 15, 2009 01:02

Hello,

the images should be set in the updateItem method. In the other case default images will be set. So, you can try to use the following approach:

if (tree.getLevel(nodeId) > 0 ) {

  tree.updateItem(nodeId,"newLabel",tree.getItemImage(nodeId,0),tree.getItemImage(nodeId,1),tree.getItemImage(nodeId,2));
  tree.selectItem(nodeId, false);

}

Answer posted by Abbie on Dec 15, 2009 09:31
This is great! Thanks!