:: Forum >> Version 2 >>

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
Thursday, February 22, 2007
finally got it.... thanks for nothing :P just kidding guys! jeje
Rauldinho
Thursday, February 22, 2007
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(colrow){
    return 
this.getData(4row); // image in the 5th column (as defined in XPath)
}


var 
grid = new AW.UI.Grid;
grid.setId("myGrid");
grid.setCellTemplate(new AW.Templates.ImageText1); // 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(colrow){
    return 
this.getNode(colrow).getAttribute("code");
}


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

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



This topic is archived.

Back to support forum

Forum search