3.0.5

Image template

Alex,

can you help me understand how I can use the Image template and the xml data model?

For example, I have a xml document with a node called "objecttype" which contains strings such as "account", contact", etc. and I would like to display "account.gif" and "contact.gif" instead of the string.

Thanks
Jeremie
May 24,
Alex, can you help?
Jeremie
May 28,
To display images you have to do three things. First, you have to define code names for the images and map them to image URLs through CSS background rule:
/* account */
.active-image-account {background: url(/images/account.gif)}

/* contact */
.active-image-contact {background: url(/images/contact.gif)}

Then you have to overload getImage method of the data model so that it will return your image code name (i.e. "account", "contact", etc.).
var table = new Active.XML.Table;
...
table.getImage = function(i, j){
    var node = this.getNode(i, j);
    return node ? node.text : "none";
};

And finally you have to assign an image template to the desired column:
var image = new Active.Templates.Image;
obj.setColumnTemplate(image, 0);

normally Active.Templates.Image displays both image and text. If you don't need the text - you can remove it with the following code:
image.setContent("text", "");

Alex (ActiveWidgets)
May 28,
Alex,

don't know why I did not see this post earlier (I posted the 'Totally unclear').

I now finally understand how this works.

Thanks a lot!
Rolf
July 7,

This topic is archived.

See also:


Back to support forum