0

Want to know how we can able to set specific image for each node in dynatree. I am getting one image from db as byte array in backend side and i am converting into Base64 String type and sending it through JSON object to client side and in the client side i am using it. In javascript with the help of <img src=""> tag we can able to display the image.

But in dynatree i saw code is like:

$("#navTree").dynatree({
    title: "Dyna Tree",
    imagePath: "$link.getContextPath()/jQuery/dynatree/skin-eac/",
    initAjax: {
        url: "getEmployee.do",
        data: {
            root: "source"
        }
    }

Image path is always taking static icon/image from pre-defined path now i want to show here dynamic image which i am getting through json object.

Can anyone please point me what exactly needs to be done.Gone through many links but not able to find out .Thanks

urbz
  • 2,663
  • 1
  • 19
  • 29
Uday Konduru
  • 203
  • 1
  • 4
  • 16

1 Answers1

0

If you want to apply a new image to the node then you can change the css style of the element while rendering the nodes using something the following:

$('#tree').dynatree({
    // ...
    onRender: function(node, nodeSpan) {
        $(nodeSpan)
        .find(".dynatree-icon")
        .css("background", "url(../abc/xyz.png) no-repeat");
    }
});
The Alpha
  • 143,660
  • 29
  • 287
  • 307
user3006723
  • 3
  • 1
  • 3