3.2.0

Javascript: Dynamically loading grid in classic asp

I am trying to dynamicall load the grid using an object but in vain

I have 2 code snipnets:

data = "Contract1":["S1234", "62,615.266","7-Dec-2007"],
"Contract1":["S1234", "62,615.266","7-Dec-2007"]

if 'data' is an asp variable

<script>
var myData = {<%=data %>};
grid.setDataText(function(i, j){return myData[i][j]});
grid.setProperty("selection/index", 0);
grid.refresh();
</script>

works fine

However if 'data' is javascript variable

<script>
var myData = {data };
grid.setDataText(function(i, j){return myData[i][j]});
grid.setProperty("selection/index", 0);
grid.refresh();
</script>

doesn't work. What could be wrong somebody help!

Peter Muchiri
February 10,
I'm not into ASP, but in javascript, the array should look like this:

e.g.

We want a grid with 3 columns: ID, name, description

data: ID=1, name=Peter, description=ASP freak
ID=2, name=Rekcor, description=Javascript freak

In javascript it would look like this:

myColumns = ['ID', 'name', 'description'];
myData = [ ['1', 'Peter', 'ASP freak'], ['2', 'Rekcor', 'Javascript freak'] ];

var grid = new Active.Controls.Grid;
grid.name = 'myGridName';

grid.setRowCount(2);
grid.setColumnCount(3);

grid.setDataText(function(i, j){return myData[i][j]});
grid.setColumnText(function(i){return myColumns[i]});
document.write(grid);


Hope this helps.
Rekcor
February 14,

This topic is archived.

See also:


Back to support forum