3.2.0

images in grid (II)

Hi,
Is there a way to get two different images in two different columns in the same row?. Thanks
Alejandro Iglesias
January 7,
Yes, sure.

There are several steps in adding images:

1. create CSS file, which translates image code-name to the image file path:

.active-image-name1 {background: url(path1)}
.active-image-name2 {background: url(path2)}
...

you can put several images into one file and use background-position
(see example at /source/styles/classic/images.css)

2. create data array for images, similar to text array:

var myImages = [
["name1", "name2", ... ],
["name3", "name4", ... ]
];

(for columns without images put "none" as an image name)

3. use Active.Templates.Image cell template instead of default one:

obj.setTemplate("cell", new Active.Templates.Image, 0);

4. link your data text and images:

obj.setProperty("data/text", function(i, j){return myData[i][j]});
obj.setProperty("data/image", function(i, j){return myImages[i][j]});


I'll try to write a tutorial section about images with more details.
Alex (ActiveWidgets)
January 7,
Can you paste some code I'm lost...
Sergio
September 6,
php. Java, or html

var myImages = [
["name1", "name2", ... ],
["name3", "name4", ... ]
];

WTF how can I use this in case of 20 Gif images who I want to show one by one, every visitor another random image...

Help??
September 16,
Make an array with image names and fill the data with a random function for example.
John Ophof http://open-modeling.sourceforge.net
September 16,

This topic is archived.

See also:


Back to support forum