:: Forum >>
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
Monday, May 24, 2004
Alex, can you help?
Jeremie
Friday, May 28, 2004
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:
.active-image-account {background: url(/images/account.gif)}
.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)
Friday, May 28, 2004
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
Thursday, July 7, 2005
This topic is archived.
Back to support forum
Forum search