:: Forum >> Version 2 >>

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
Monday, September 17, 2007
You should specify the column index -

var header = obj.getHeaderTemplate(1); // column-1
header.getContent("box").setStyle("background", "red");
Alex (ActiveWidgets)
Monday, September 17, 2007
I try to specify the column index, but not working!! Why??
My Code:

<html>
<
head>
    <
title>ActiveWidgets Grid :: Examples</title>
    <
stylebodyhtml {margin:0pxpadding0pxoverflowhidden;} </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([strstrnumnumnum]);

    
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(eventcolrow){window.status this.getCellText(colrow)};

var 
header obj.getHeaderTemplate(1); // column-1
header.getContent("box").setStyle("background""red");

    
document.write(obj);

    </
script>
</
body>
</
html
Andy
Thursday, September 20, 2007
Somebody help me?
Andy
Monday, October 1, 2007
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)
Monday, October 1, 2007
I upgraded aw.js from 2.01 to 2.02 version, that's working. Why?
Andy
Tuesday, October 2, 2007
There was a bug in 2.0.1 where changes on the inner content were not saved.
Alex (ActiveWidgets)
Wednesday, October 3, 2007



This topic is archived.

Back to support forum

Forum search