3.2.0

CellImages on wrong row

Seems I have got the cellimages to appear on the grid with the foloowing code.

obj.setCellTemplate(new AW.Templates.ImageText,6);
obj.setCellTemplate(new AW.Templates.ImageText,7); 
obj.setCellText(function(col, row){
var tmp;
if (col==6) {
    this.setCellImage(data[row][col],col);
    return "";
} else if (col==7) {
    this.setCellImage(data[row][col],col);
    return data[row][col];
} else {
    return data[row][col];
}
});


The images are appearing, but are offset by on row. Meaning, the first row does not contain an image, and the second row contains the first rows image, and all subsequent rows have the previous rows image. Is this a bug in beta 4?
Tony
January 23,
Tony,

you should not call setCellImage on each call to setCellText function, it is enough to do it just once. You can also use AW.Templates.Image if you don't want text in this cell. On the first glance your code could look like this -

obj.setCellTemplate(new AW.Templates.Image, 6);
obj.setCellTemplate(new AW.Templates.ImageText, 7); 
obj.setCellText(data);
obj.setCellImage(data);
Alex (ActiveWidgets)
January 23,
Thanks for the help Alex, it's much appreciated, but no luck, as soon as a swapped my code with the 2 calls you recommended, the grid displays, but without data. Take a look here

http://office.twtserver.com/plh_iface/index.php
Tony
January 23,
Maybe inside getVisitors() function you should call

users.setCellText(visitors);
users.setCellImage(visitors);
Alex (ActiveWidgets)
January 23,
Those changes should work. I looked at the returned data and it's fine so there doesn't seem to be anything wrong on the server side. You just need to re-assign the array to the grid so that the indexes get re-initialized. You can't change data by simply changing the array and calling refresh(), it just won't work. You need to re-apply the array to the grid, set the row count, then call refresh().

I like the way your interface is looking and that you created it by creating a new control and combining it with the grids. I like to see people extending the toolkit instead of just using it in it's most basic form. This is a toolkit, might as well take advantage of that!

Jim Hunter
January 23,
Thanks Alex putting the 2 lines in getVisitors() fixed the images problem. My question is, since I would also like to display the version for certain columns along with the image. In my first function for setCellText I was parsing some data and returning the version for the cell text and setting the cellimage with the browser. How can I include the version in the text, but keep the image for the text displayed? Maybe add another column in the data, but only have that for the text in that column with the image? What would be the best approach?

I guess as far as using a table with the grid and % just seems to be troublesome since all the browsers are treating it differently. I guess I am going to have to emulate a table with divs and spans as active widgets does. Perhaps the AW HTML or TEMPLATES may have a solution for me? I am going to have to play around with the code.

Tony
January 24,

This topic is archived.

See also:


Back to support forum