Grid is null or not an object (at loading)
Hello!
I was recently forced to check an old projects code, written by a colleague I never met, using widgets version 1.0.1.
I have no idea how the components work, but spending some time on the forum I found out that other people as well experienced problems, like the grid not loading correctly everytime for no apparent reason. SO here is the code emitted on my page.
I would appreciate it, if you took a brief look at it and see if there is some known work-around that I am not aware of.
Here's the code:
<!-- Grid script -->
<script>
var string = new Active.Formats.String;
var date = new Active.Formats.Date;
date.setTextFormat("d mmm");
date.setDataFormat("RFC822");
var gridPositions = new Active.Controls.Grid;
</script>
<script>
gridPositions.setColumnProperty("texts", ["Device ID", "", "???a??da", "?e????af?","?µe??µ???a","?a??t?ta","??p??es?a", ""]);
</script>
<script>
gridPositions.setRowHeaderWidth("0px");
// Event On Selection Changed
selectionChangedFunction = function(src){
findDevice(this.getDataText(gridPositions.getSelectionProperty("index"),0));
gridPositions.setAction("selectionChanged", selectionChangedFunction);
// Alternate Grid Background Colors URL:
//http://www.activewidgets.com/grid.howto.style.rows/alternate-background-colors.html
alternate = function(){
return this.getRowProperty("order") % 2 ? "#fcfaf6" : "#ffffff";
}
var row = new Active.Templates.Row;
row.setStyle('background', alternate);
gridPositions.setTemplate('row', row);
//var image = new Active.HTML.IMG;
//image.setAttribute("SRC","./Images/tbping.gif");
//image.setStyle('height',16);
//image.setStyle('width',21);
//var pingFunction = function(){pingDevice(gridPositions.getDataText(gridPositions.getSelectionProperty("index"),0),2);}
//var pingFunction = function(src){alert(src.getColumnProperty('index'));
}
//image.setEvent("onclick", pingFunction);
//gridPositions.setColumnTemplate(image,7);
// add tooltips to the first column template and data model
gridPositions.getColumnTemplate(7).setAttribute("title", function(){return this.getItemProperty("tooltipPing")});
gridPositions.defineDataProperty("tooltipPing", function(i, j){return "Ping"});
// add tooltips to the first column template and data model </script>
<script>
gridPositions.getColumnTemplate(1).setAttribute("title", function(){return this.getItemProperty("tooltipData")});
gridPositions.getColumnTemplate(2).setAttribute("title", function(){return this.getItemProperty("tooltipData")});
gridPositions.getColumnTemplate(3).setAttribute("title", function(){return this.getItemProperty("tooltipData")});
gridPositions.getColumnTemplate(4).setAttribute("title", function(){return this.getItemProperty("tooltipData")});
gridPositions.getColumnTemplate(5).setAttribute("title", function(){return this.getItemProperty("tooltipData")});
gridPositions.getColumnTemplate(6).setAttribute("title", function(){return this.getItemProperty("tooltipData")});
gridPositions.defineDataProperty("tooltipData", function(i, j){return this.getDataText(i,j)});
// Disable sorting for image columns
var _sort = gridPositions.sort;
gridPositions.sort = function(index, direction){
if (index == 7 || index == 8){
return true;
}
else {
_sort.call(this, index, direction);
}
}
// Return to the same scrolling position after refrresh
var _refresh = gridPositions.refresh;
gridPositions.refresh = function(){
var scrollbars = gridPositions.getTemplate("layout").getContent("scrollbars");
var x = scrollbars.element().scrollLeft;
var y = scrollbars.element().scrollTop;
var data = gridPositions.getTemplate("layout").getContent("data");
var data_x = data.element().scrollLeft;
var data_y = data.element().scrollTop;
gridPositions.element().runtimeStyle.visibility = "hidden";
_refresh.call(gridPositions);
// var _obj = this;
window.setTimeout(function(){
scrollbars.element().scrollLeft = x;
scrollbars.element().scrollTop = y;
data.element().scrollLeft = data_x;
data.element().scrollTop = data_y;
//gridPositions.element().runtimeStyle.visibility = "visible";
//gridPositions.element().focus();
}, 0 );
}
document.write(gridPositions);
</script>
<!-- Grid Script-->
The message some customers are seeing is "gridPositions is null or not an object" in Internet Explorer. One customer said that after uninstalling Norton Antivirus, the grid started working again! Talk about coding madness...
Cheers!
I was recently forced to check an old projects code, written by a colleague I never met, using widgets version 1.0.1.
I have no idea how the components work, but spending some time on the forum I found out that other people as well experienced problems, like the grid not loading correctly everytime for no apparent reason. SO here is the code emitted on my page.
I would appreciate it, if you took a brief look at it and see if there is some known work-around that I am not aware of.
Here's the code:
<!-- Grid script -->
<script>
var string = new Active.Formats.String;
var date = new Active.Formats.Date;
date.setTextFormat("d mmm");
date.setDataFormat("RFC822");
var gridPositions = new Active.Controls.Grid;
</script>
<script>
gridPositions.setColumnProperty("texts", ["Device ID", "", "???a??da", "?e????af?","?µe??µ???a","?a??t?ta","??p??es?a", ""]);
</script>
<script>
gridPositions.setRowHeaderWidth("0px");
// Event On Selection Changed
selectionChangedFunction = function(src){
findDevice(this.getDataText(gridPositions.getSelectionProperty("index"),0));
gridPositions.setAction("selectionChanged", selectionChangedFunction);
// Alternate Grid Background Colors URL:
//http://www.activewidgets.com/grid.howto.style.rows/alternate-background-colors.html
alternate = function(){
return this.getRowProperty("order") % 2 ? "#fcfaf6" : "#ffffff";
}
var row = new Active.Templates.Row;
row.setStyle('background', alternate);
gridPositions.setTemplate('row', row);
//var image = new Active.HTML.IMG;
//image.setAttribute("SRC","./Images/tbping.gif");
//image.setStyle('height',16);
//image.setStyle('width',21);
//var pingFunction = function(){pingDevice(gridPositions.getDataText(gridPositions.getSelectionProperty("index"),0),2);}
//var pingFunction = function(src){alert(src.getColumnProperty('index'));
}
//image.setEvent("onclick", pingFunction);
//gridPositions.setColumnTemplate(image,7);
// add tooltips to the first column template and data model
gridPositions.getColumnTemplate(7).setAttribute("title", function(){return this.getItemProperty("tooltipPing")});
gridPositions.defineDataProperty("tooltipPing", function(i, j){return "Ping"});
// add tooltips to the first column template and data model </script>
<script>
gridPositions.getColumnTemplate(1).setAttribute("title", function(){return this.getItemProperty("tooltipData")});
gridPositions.getColumnTemplate(2).setAttribute("title", function(){return this.getItemProperty("tooltipData")});
gridPositions.getColumnTemplate(3).setAttribute("title", function(){return this.getItemProperty("tooltipData")});
gridPositions.getColumnTemplate(4).setAttribute("title", function(){return this.getItemProperty("tooltipData")});
gridPositions.getColumnTemplate(5).setAttribute("title", function(){return this.getItemProperty("tooltipData")});
gridPositions.getColumnTemplate(6).setAttribute("title", function(){return this.getItemProperty("tooltipData")});
gridPositions.defineDataProperty("tooltipData", function(i, j){return this.getDataText(i,j)});
// Disable sorting for image columns
var _sort = gridPositions.sort;
gridPositions.sort = function(index, direction){
if (index == 7 || index == 8){
return true;
}
else {
_sort.call(this, index, direction);
}
}
// Return to the same scrolling position after refrresh
var _refresh = gridPositions.refresh;
gridPositions.refresh = function(){
var scrollbars = gridPositions.getTemplate("layout").getContent("scrollbars");
var x = scrollbars.element().scrollLeft;
var y = scrollbars.element().scrollTop;
var data = gridPositions.getTemplate("layout").getContent("data");
var data_x = data.element().scrollLeft;
var data_y = data.element().scrollTop;
gridPositions.element().runtimeStyle.visibility = "hidden";
_refresh.call(gridPositions);
// var _obj = this;
window.setTimeout(function(){
scrollbars.element().scrollLeft = x;
scrollbars.element().scrollTop = y;
data.element().scrollLeft = data_x;
data.element().scrollTop = data_y;
//gridPositions.element().runtimeStyle.visibility = "visible";
//gridPositions.element().focus();
}, 0 );
}
document.write(gridPositions);
</script>
<!-- Grid Script-->
The message some customers are seeing is "gridPositions is null or not an object" in Internet Explorer. One customer said that after uninstalling Norton Antivirus, the grid started working again! Talk about coding madness...
Cheers!
Angie
April 26,