:: Forum >>

XML data based grid change row background if one of the value matches the condtion

Hi,

I got the active widgets grid and the XML is used to display the data in the grid

// create ActiveWidgets data model - XML-based table
var table1 = new AW.XML.Table;

// specify rows XPath
table1.setRows("//iSites/submissions");

var myColumns1 = ["@val0","@val1","@val2", "@val3", "@val4"];

table1.setColumns(myColumns1);

var obj = new AW.Grid.Extended;
obj.setSelectionMode("single-row");
obj.setId("myGrid1");
obj.setColumnCount(5);

var value = obj.getRowPosition();
obj.setRowPosition(value);
var myHeaders = ["Col0","Col1","Col2","Col3", "Col4"];
obj.setHeaderText(myHeaders);

var celvalue = obj.getCurrentRow();
alert(celvalue);
obj.setSelectorVisible(true);
obj.setSelectorWidth(30);
obj.setSelectorText(function(i){return this.getRowPosition(i)+1});

obj.setControlSize(699, 625);
obj.setCellModel(table1);

table1.response(xml);

in this i wanted to check if the particular val3 = 432 then the background should be red for that row..

Can anyone please let me know how do i achieve that
Vijay
Thursday, January 18, 2007
You have to define calculated row background property and assign it to the row template background style -

// define new property for the rows
obj.defineRowProperty("background", function(row){
    var col = 3; // use text from the 4th column
    var text = this.getCellProperty("text", col, row);
    return text == 432 ? "red": "white";
});

// assign row background property to the background style
obj.getRowTemplate().setStyle("background", function(){
    return this.getRowProperty("background");
});
Alex (ActiveWidgets)
Friday, January 19, 2007

This topic is archived.


Back to support forum

Forum search