From a main page, I want to add, update or delete the contents of the GRID that I have referenced in an iframe. It appears to be that I lose the object ('this.girdData' is null or not an object) from the page called in the iframe.
<html>
...
...
<td colspan="4" align="left" nowrap bgcolor="#C9D3DE">
<iframe src="epli/basic.htm" id="Schedules4i" name="Schedules4i"
frameborder="0" width="100%" height="100"></iframe>
</td>
...
...
<td colspan="4" nowrap>
<input id="btnAddUpdate" type="button"
onclick="frames.Schedules4i.obj.addOrUpdateRow()"
value="Add" style="width: 120px;" />
<input id="btnDelete" type="button"
onclick="frames.Schedules4i.obj.deleteRow()"
value="Delete Selected Row(s)" disabled="disabled" />
<input id="btnClearAll" type="button"
onclick="frames.Schedules4i.obj.clearAll()"
value="Clear All" style="width: 120px;" />
</td>
...
...
</html>
Here is the page that contains the GRID.
<html>
<head>
<title>ActiveWidgets Grid :: Examples</title>
<style> body, html {margin:0px; padding: 0px; overflow: hidden;} </style>
<!-- ActiveWidgets stylesheet and scripts -->
<link rel="stylesheet" type="text/css" href="../../../runtime/styles/classic/grid.css">
<script src="../../../runtime/lib/grid.js"></script>
<!-- grid format -->
<style>
.active-controls-grid {height: 100%; font: menu;}
.active-column-0 {width: 150px;}
.active-column-1 {width: 100px;}
.active-column-2 {text-align: right;}
.active-column-3 {text-align: right;}
.active-grid-column {border-right: 1px solid threedlightshadow;}
.active-grid-row {border-bottom: 1px solid threedlightshadow;}
</style>
</head>
<body>
<script>
// create data formats
var string1 = new Active.Formats.String;
var number1 = new Active.Formats.Number;
var date1 = new Active.Formats.Date;
var number2 = new Active.Formats.Number;
// define formatting rule for text output
number1.setTextFormat("#,###");
number2.setTextFormat("#,###");
date1.setTextFormat("mm dd yyyy");
date1.setDataFormat("ISO8061");
// create ActiveWidgets data model - XML-based table
var table = new Active.XML.Table;
// provide data URL
table.setURL("epli.xml");
// define namespace for selecting column data
table.setNamespace("co", "
http://tempuri.org/");
// set column XPath
table.setColumns(["co:nature-of-business", "co:number-of-employees", "co:retroactive-date", "co:employees-cov-by-plan"]);
// set column formatting
table.setFormats([string1, number1, date1, number2]);
// start asyncronous data retrieval
table.request();
// define column labels
var columns = ["Nature of Business", "Number of Employees", "Retroactive Date", "Employees covered by plan"];
// create ActiveWidgets Grid javascript object
var obj = new Active.Controls.Grid;
// provide column labels
obj.setColumnProperty("texts", columns);
// provide external model as a grid data source
obj.setDataModel(table);
// write grid html to the page
// enable multiple selection
// obj.setProperty("selection/multiple", true);
// write grid html to the page
document.write(obj);
obj.resetRowValues = function() {
// re-initialize the grid data model
this.setDataProperty("count", this.gridData.length);
this.setRowProperty("value", function(i){return i});
this.setRowProperty("order", function(i){return i});
this.setSortProperty("index", null);
this.setSelectionProperty("index", -1);
this.setSelectionProperty("values", []);
this.refresh();
}
obj.showRow = function() {
var selectionIndex = this.getProperty("selection/index");
if(selectionIndex >= 0) {
parent.document.frmSchedules4.btnAddUpdate.value = " Update ";
parent.document.frmSchedules4.btnDelete.disabled = false;
parent.document.frmSchedules4.textfield0.value = this.getDataProperty("text", selectionIndex, 0);
parent.document.frmSchedules4.textfield1.value = this.getDataProperty("text", selectionIndex, 1);
parent.document.frmSchedules4.textfield2.value = this.getDataProperty("text", selectionIndex, 2);
parent.document.frmSchedules4.textfield3.value = this.getDataProperty("text", selectionIndex, 3);
}
}
obj.setAction("selectionChanged", obj.showRow);
obj.addOrUpdateRow = function() {
var selectionIndex = this.getProperty("selection/index");
var aRecord = [ parent.document.frmSchedules4.textfield0.value,
parent.document.frmSchedules4.textfield1.value,
parent.document.frmSchedules4.textfield2.value,
parent.document.frmSchedules4.textfield3.value ];
if(selectionIndex >= 0) {
alert("selectionIndex =" + selectionIndex);
alert("aRecord =" + aRecord);
this.gridData.splice(selectionIndex, 1, aRecord);
} else {
this.gridData.unshift(aRecord);
}
this.clearAll();
}
obj.deleteRow = function() {
var selectionValues = this.getProperty("selection/values");
if(selectionValues.length > 0) {
selectionValues.sort();
for(var i = selectionValues.length -1; i >= 0 ; --i) {
this.gridData.splice(selectionValues[i], 1);
}
this.clearAll();
}
}
obj.clearAll = function() {
this.resetRowValues();
// clear form
parent.document.frmSchedules4.btnAddUpdate.value = " Add ";
parent.document.frmSchedules4.btnDelete.disabled = true;
parent.document.forms.entryForm.reset();
}
</script>
</body>
</html>
Joe
Could you give me an example. I tried a few things, but they're not working.
It seems that referense to this.gridData was copied from the code based on js array data model. In you case (XML data model) you have to modify row functions.
oh - change anything and everything in the url - but leave the timeurl2 variable and what makes it so you dont catch
This topic is archived.