3.2.0

How do I refer to a control outside of that control?

Here’s a really simple example. I have a grid and I want to populate a cell in that grid by referring to it outside the script block. I’m trying to make this simple. I know I can do it within the script block but I have a need to refer to the grid outside of the grid control itself and outside of the script:

<script type="text/javascript">
var grid2 = new AW.Grid.Extended;
grid2.setId("grid2");
grid2.setHeaderText(["UPC", "Description", "Quantity", "Price", "Total", "Taxable"]);
grid2.setFooterText(["Subtotal","","Sales Tax:","","Total",""]);
grid2.setFooterVisible(true);
grid2.setColumnCount(6);
grid2.setRowCount(10);
grid2.setCellEditable(true,0);
grid2.setCellEditable(true,2);
grid2.setCellEditable(true,3);
grid2.setCellEditable(true,5);
grid2.refresh();
</script>

<br>
<input type='button' onclick=" document.getElementById(‘grid2.setCellText(\’pressed button\’,1,10)’);" value='Test' name='btnTest'/>

Thanks,

Chris
Chris
April 14,
Never mind...sheesh

<input type='button' onclick="grid2.setCellText('pressed button',1,10);" value='Test' name='btnTest'/>

I was making it way too complicated.

Chris
Chris
April 14,
You could make it even less complicated by using an AW button rather than writing some HTML code.
Anthony
April 14,
Again, note that I said that this was a simple example. The need is not for a button. The need is to be able to refer to a control outside of that control and outside of the script that defined the control as I very clearly stated in my orginal post.

Thanks for the input, though.

Chris
Chris
April 14,
Objects in script blocks are not invisible to each other. Any object in the DOM is visible to any other. You can easily test this by doing something like -
<script>
var grid = new AW.UI.Grid
...
document.write(grid)
</script>
<br>
<script>
var but = new AW.UI.Button
... access the grid in a function here ...
document.write(but)
</script>
Anthony
April 14,
I needed to take it one step further and refer to it from another window and it works just as it's supposed to:

window.parent.grid2.setCellText('some stuff',0,0)

Chris
Chris
April 15,

This topic is archived.

See also:


Back to support forum