:: Forum >> Version 2 >>

input box in header

Hi Alex,

The following code to put an input box in the 1st column header on header click fails in 2.5.1 and works in 2.0.2
In 2.5.1, if I replace obj.getHeaderTemplate(1, 1).refresh(); with obj.refresh(), it works.
However, refreshing the entire grid to update one header cell is not the best way.
Could you please give a solution to this ?

Also, I'm not sure if its related to /javascript.forum.21810.1/combo-in-grid-on-double.html
There too, I had to use obj.getRowTemplate(row).refresh() instead of obj.getCellTemplate(col, row).refresh()


<html>
<
head>
    <
script src="runtime/lib/aw.js"></script>
    <
link href="runtime/styles/xp/aw.css" rel="stylesheet"></link>

<
style>
#myInput {width150pxheight25px}
</
style>

</
head>
<
body>

<
script

    var 
obj = new AW.Grid.Extended
    
obj.setSize(800250);
    
obj.setCellText(function(ij){return "-" i});
    
obj.setHeaderCount(2);
    
obj.setHeaderText("header");
    
obj.setHeaderText(["sub 0""sub 1""sub 2""Sub 3""Sub 4""Sub 5""Sub 6""Sub 7""Sub 

8"
"Sub 9"], 1);

    
obj.setColumnCount(10); 
    
obj.setRowCount(10); 

    
obj.onHeaderClicked = function() {

        var 
inp = new AW.UI.Input;
        
inp.setId("myInput");
        
inp.setControlText("Some text");
        
inp.setControlImage("favorites");

        
obj.setHeaderTemplate(inp11);
        
inp.setAttribute("aw""control");

        
obj.getHeaderTemplate(11).refresh();
        
//obj.refresh();

    
}

    
document.write(obj);

</
script>  

</
body>
</
html>
 
Ankur Motreja
Tuesday, February 12, 2008
Refresh method in AW 2.5 item/cell/header templates repaints only the text, image, styles and classes (and not the complete html) for better performance. When you replace one template with another you have to refresh the parent element, in this case the header row (headersTemplate).

obj.onHeaderClicked = function() {

        var 
inp = new AW.UI.Input;
        
inp.setId("myInput");
        
inp.setControlText("Some text");
        
inp.setControlImage("favorites");

        
this.setHeaderTemplate(inp11);
        
this.getHeadersTemplate(1"center").refresh();
    }
 
Alex (ActiveWidgets)
Tuesday, February 12, 2008
ok. Now it all makes sense :)
Its working now.
Thanks Alex.

Ankur
Ankur Motreja
Tuesday, February 12, 2008

Post a reply:

Text:
Name:

Back to support forum

Forum search