3.2.0

XML & Cell Image

hi, i'm havin trouble displaying an image in a cell using XML as my data source. Can someone post a code that shows the right way to do so please. I need help on this one!!! :(
Rauldinho
February 22,
finally got it.... thanks for nothing :P just kidding guys! jeje
Rauldinho
February 22,
You have to add getImage() method to your XML datasource.

Option 1 - the image code is in another column (element).

Add the image column to the XPath (as a last one). Return the last column value from the getImage() method -

var data = new AW.XML.Table;
data.setURL("image-element.xml");
data.setColumns(["rank", "country", "users", "year", "code"]);
data.request();

// add getImage method returning 'image' column value
data.getImage = function(col, row){
    return this.getData(4, row); // image in the 5th column (as defined in XPath)
}


var grid = new AW.UI.Grid;
grid.setId("myGrid");
grid.setCellTemplate(new AW.Templates.ImageText, 1); // image & text template for the 2nd column
grid.setColumnCount(4);
grid.refresh();

// attach external data model
grid.setCellModel(data);


Option 2 - the image code is in the node attribute.

Add getImage() method which retrieves the node attribute -

var data = new AW.XML.Table;
data.setURL("image-attribute.xml");
data.request();

// add getImage method returning 'code' attribute for each node
data.getImage = function(col, row){
    return this.getNode(col, row).getAttribute("code");
}


var grid = new AW.UI.Grid;
grid.setId("myGrid");
grid.setCellTemplate(new AW.Templates.ImageText, 1); // image & text template for the 2nd column
grid.setColumnCount(4);
grid.refresh();

// attach external data model
grid.setCellModel(data);
Alex (ActiveWidgets)
February 22,
Oops, too late :-)
Alex (ActiveWidgets)
February 22,

This topic is archived.

See also:


Back to support forum