:: Forum >> Version 1 >>

How to create a grid on click event

I try to create a grid after the user click a button, but it doesn't work for the following code:
.active-controls-grid {height: 100%; font: menu;}
.active-column-0 {width: 80px;}
.active-column-1 {width: 200px;}
.active-column-2 {text-align: right;}
.active-column-3 {text-align: right;}
.active-column-4 {text-align: right;}

function create()
var myData = [
["MSFT","Microsoft", "314,571.156", "32,187.000", "55000"],
["ORCL", "Oracle", "62,615.266", "9,519.000", "40650"],
["KNM", "Konami (ADR)", "3,710.784", ".000", "4313"]

var myColumns = ["Ticker", "Company Name", "Market Cap.", "$ Sales", "Employees"];
var obj = new Active.Controls.Grid;
obj.setRowProperty("count", 20);
obj.setColumnProperty("count", 5);
obj.setDataProperty("text", function(i, j){return myData[i][j]});
obj.setColumnProperty("text", function(i){return myColumns[i]});
obj.setAction("click", function(src){window.status = src.getItemProperty("text")});
<p><a href="javascript:create()">creategrid</a></p>

Any comments are highly appreciated.
Monday, August 23, 2004
You can only use document.write(...) during the page load. In your case you have to replace document.write(obj) with the following:

document.getElementById("grid_parent").innerHTML = obj;

and also add grid_parent DIV

<p><a href="javascript:create()">creategrid</a></p>
<div id="grid_parent"></div>
Alex (ActiveWidgets)
Monday, August 23, 2004
Thank you so much, Alex.
Monday, August 23, 2004
Even simpler

function hideGrid() { 
showGrid() { 
Sudhaker Raj
Monday, August 23, 2004

And put grid at it's normal location. This is more suitable if you need to do 'hide it' as well else what Alex suggested is more efficient (create only when needed)...
Sudhaker Raj
Monday, August 23, 2004
Does the innerHTML suggestion work? I've been trying various methods and all I can get is the text "[object]" displayed where I want the grid to be displayed. Using the Create function described above, if I swap out the document.write with the innerHTML of an object, I get the [object] text displayed in the DIV instead of the grid.

Any other suggestions?
G. Winston
Monday, January 3, 2005
Hi All

I have succesfully written a grid to a div tag using the document.getElementById("grid_parent").innerHTML = obj;
when a button is clicked by the user. The grid is generated in a Javascript function and written to the div tag.

My problem is the scroll bar (horizontal) is not functioning properly when I resize the columns of the grid. The first time I resize, the scroll bar doesn't even appear. I resize a column again at which point the scroll bar appears. But it is out of sync with the column sizes.

I'm wondering if the scroll bars are acting up because I am writing it to a div tag. The most common use, grids are being generated when a page is loaded and the scroll bar functionality has been fine for most. Has anyone else come across this case where they are writing to a div tag and using scroll bars? I can provide the coding if you need it.

Any help would be greatly appreciated. Thanks.

Tuesday, April 19, 2005
Hello All

I have a problem I am working with customed datecontrol..
when I open the calendar it opens with the specified textbox..by getting the location of parent tag...

Now the problem is..when i place the control in <DIV> tags it gets the location wrong..
The problem can be solved if I can get the count of the scrollbar..i.e. by how much pixels or %age it has been moved vertically down from the top....

If anyone can suggest me a solution plz mail me at

Jaswinder Singh
Thursday, June 29, 2006
please send how to create a dialpad with 1 to 10 numbers in dhtml using javascript
Tuesday, August 1, 2006

This topic is archived.

Back to support forum

Forum search