3.2.0

I am new to Javascript and hoping that someone can help a frustrated person.(me)

I have been able to use the sample to load my csv file, as long as it is loaded in the directory that is loaded with the page originally.

When I click on the button, nothing happens. When I click on the table it does not load the new file into the grid.

<html>
<head>
<style> body, html {margin:0px; padding: 0px; overflow: hidden;} </style>

<!-- ActiveWidgets stylesheet and scripts -->
<link href="./ActiveWidgets/runtime/styles/classic/grid.css" rel="stylesheet" type="text/css" ></link>
<script src="./ActiveWidgets/runtime/lib/grid.js"></script>

<!-- grid format -->
<style>
.active-controls-grid {height: 200px; font: menu;width: 304}

.active-column-0 {width: 100px;}
.active-column-1 {width: 80px; background-color: threedlightshadow;}
.active-column-2 {width: 80px; }
//.active-column-2 {text-align: right;}
//.active-column-3 {text-align: right;}
//.active-column-4 {text-align: right;}

.active-grid-column {border-right: 1px solid threedshadow;}
.active-grid-row {border-bottom: 1px solid threedlightshadow;}
</style>
</head>
<body>
<script>
var table = new Active.Text.Table; // create ActiveWidgets data model - text-based table
table.setURL("./test.csv"); // provide data URL - plain text comma-separated file
table.request(); // start asyncronous data retrieval
var columns = ["ComponentName", "Column", "Row"]; // define column labels
var obj = new Active.Controls.Grid; // create ActiveWidgets Grid javascript object
obj.setId("grid1");
obj.setProperty("column/count", 3);
obj.setColumnProperty("texts", columns); // provide column labels
obj.setDataModel(table); // provide external model as a grid data source
obj.setSelectionProperty("multiple", true);
document.write(obj); // write grid html to the page
obj.setAction("click", function()
{
var Datalen = 0;
var myData =[];
var hhh=document.ui.ModelName.value;
//alert(hhh);
table.setURL(hhh);
table.request(); // start asyncronous data retrieval
var columns = ["ComponentName", "Column", "Row"]; // define column labels
var obj = new Active.Controls.Grid; // create ActiveWidgets Grid javascript object
obj.setId("grid1");
obj.setProperty("column/count", 3);
obj.setColumnProperty("texts", columns); // provide column labels
obj.setDataModel(table); // provide external model as a grid data source
obj.setSelectionProperty("multiple", true);
document.write(obj);
var i, s = "", max = this.getRowProperty("count");
for (i=0; i<max; i++)
{
var index = this.getRowProperty("value", i);
//alert(index);
s += this.getDataProperty("text", index, 0) + " "+this.getDataProperty("text", index, 1) + " "+this.getDataProperty("text", index, 2) ;
}

alert(s);
});
</script>
<form NAME="ui">
<table border=0>
<td width="135">
<p align="center"><big><big><em><strong>CSV to Load</strong></em></big></big></p>
<p align="center"><input type="text" name="ModelName" SIZE="5"></p>
</td>
</table>
</form>
<spacer size=20>
<input type="button" value="Load this File" onclick="function()">
</body>
</html>
Allen
April 3,
Your problem lies in the fact that you haven't told your button to actually do anything or your onclick handler.

try adding this atthe head of your script

function HelloWorld() {
alert('hello world');
}

Then change your button html to :

<input type="button" value=Say Hi" onclick="HelloWorld();return false">

pcasey@earthlink.net
April 3,

This topic is archived.

See also:


Back to support forum