:: Forum >>

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 http://www.activewidgets.com/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 {width: 150px; height: 25px}
</style>

</head>
<body>

<script>

var obj = new AW.Grid.Extended;
obj.setSize(800, 250);
obj.setCellText(function(i, j){return j + "-" + 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(inp, 1, 1);
inp.setAttribute("aw", "control");

obj.getHeaderTemplate(1, 1).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(inp, 1, 1);
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

This topic is archived.


Back to support forum

Forum search