Programatically change header background not css
I would need to change a specific header's background color. I've seen some great examples but none that quite tell me what I need to do.
I try
obj.getHeaderTemplate().getContent("box").setStyle("background", "red");
or obj.getHeaderTemplate().setStyle("backgroundColor", "red");
but not working.
Can anyone help ?
Andy
September 17,
You should specify the column index -
var header = obj.getHeaderTemplate(1); // column-1
header.getContent("box").setStyle("background", "red");
Alex (ActiveWidgets)
September 17,
I try to specify the column index, but not working!! Why??
My Code:
<html>
<head>
<title>ActiveWidgets Grid :: Examples</title>
<style> body, html {margin:0px; padding: 0px; overflow: hidden;} </style>
<link href="../../runtime/styles/xp/aw.css" rel="stylesheet" type="text/css" ></link>
<script src="../../runtime/lib/aw.js"></script>
<script>
var myData = [
["MSFT","Microsoft Corporation", "314,571.156", "32,187.000", "55000"]];
var myColumns = [
"Ticker", "Company Name", "Market Cap.", "$ Sales", "Employees"
];
</script>
</head>
<body>
<script>
var obj = new AW.UI.Grid;
var str = new AW.Formats.String;
var num = new AW.Formats.Number;
obj.setCellFormat([str, str, num, num, num]);
obj.setCellText(myData);
obj.setHeaderText(myColumns);
obj.setRowCount(1);
obj.setColumnCount(5);
obj.setSelectorVisible(true);
obj.setSelectorText(function(i){return this.getRowPosition(i)+1});
obj.setSelectorWidth(28);
obj.setHeaderHeight(20);
obj.setSelectionMode("single-row");
obj.onCellClicked = function(event, col, row){window.status = this.getCellText(col, row)};
var header = obj.getHeaderTemplate(1);
header.getContent("box").setStyle("background", "red");
document.write(obj);
</script>
</body>
</html>
Andy
September 20,
Can you explain what is wrong with this code? It does change the header color to red. Are you trying to do something else?
Alex (ActiveWidgets)
October 1,
I upgraded aw.js from 2.01 to 2.02 version, that's working. Why?
Andy
October 2,
There was a bug in 2.0.1 where changes on the inner content were not saved.
Alex (ActiveWidgets)
October 3,