3.0.5

Create and display an image URL dynamically.

Hi,
I would like to do 2 things.
1 - display in a cell per line an image.
2 - build this image url on the content of one of the other cell of the line.

I use XML as data provider.
thank you!

Dragonmood
December 22,
Hi,
I have found this procedure :
http://www.activewidgets.com/messages/265-2.htm

I think I understand but it doesnt suit my requierments...
If I have to use stylesheet to store the image path it means that I wont be able to "dynamically" build the image path and having to pass by an heavy process ( manually stylesheet edition for each added image)...

For ex:
If I have a catalog of books with a cover' scan ,everytime I add books I would like to simply drop the image in a /images/thumb/ dir , (programmatically) add a node in the XML specifying the image name and let the Grid build the proper path to the cover image.

Is there a way to do that other than with a stylesheet ?
thank you for your help.



Dragonmood
December 23,
I have the same requirement: I need to display an image in a column and the path will be dynamic and I don't want to hardcode the name and path to all the GIFs in the stylesheet because images will constantly be added. Has anyone found a solution?
JeD
February 3,
http://www.activewidgets.com/javascript.forum.560.3/xml-images-in-grid-iii.html

This post has a solution. Except that it will display an image event if the XML node is missing. If anyone finds a solution to the "missing image node" please let me know.
JeD
February 7,
hello sir,

i want to create tag for transfer cad image from one place to another . my e-mail add is cool_anup1@yahoo.com.
i m waiting for your reply.

thanks.
anup
April 1,
This might be of interest here... I've reworked the image template to that dynamically (based on the data supplied) loads the image instead of relying on a defined css. It also checks to see if the image supplied is valid (loading a "default" image, that could be a blank gif, if it is not).

Active.Templates.Image = Active.System.Template.subclass();
Active.Templates.Image.create = function(){ 
    	var obj = this.prototype;
    	obj.setClass("templates", "image");
    
    	var image = new Active.HTML.SPAN;
    	image.setClass("box", "image");
    	image.setAttribute("style",function(){
      	var temp = new Image();
        temp.src = this.getItemProperty("image");
        if(temp.width)
        {
        	return "background: url('"+this.getItemProperty("image")+"')";
        }
        else
        {
        	return "background: url('DEFAULT_IMAGE_URL')";
        }
      });
    	obj.setContent("image", image);
    	obj.setContent("text", function(){return this.getItemProperty("text")});
    
    	obj.setEvent("onclick", function(){this.action("click")});
    
    }; 
    Active.Templates.Image.create();


If you don't want the "text" included with the image just comment out:

obj.setContent("text", function(){return this.getItemProperty("text")});
the12thpyro
October 11,

This topic is archived.

See also:


Back to support forum