:: Forum >>

Error: 'myData[...]' is null or not an object


Hi everyone,

I'm evaluating your software with much delight... long have i manually (server side) sorted tables, wanting a much quicker client side solution.

HOWEVER !
********

I've mocked up a simple table / grid that displays / sorts fine, yet i get a javascript error message on the IE Status bar (see above)

I'm using the latest IE 6 SP2 etc etc.

The code is below :

Cheers

Andy

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

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

<!-- grid format -->
<style>
.active-controls-grid {height: 100%; font: menu;}
.active-column-0 {width: 80px;}
.active-column-1 {width: 50px; text-align: right;}
.active-column-2 {width: 80px;}
.active-column-3 {width: 50px;}
.active-column-4 {width: 180px;}
.active-column-5 {width: 50px;}
.active-column-6 {width: 50px;background-color: threedlightshadow;}
.active-column-7 {width: 50px;background-color: threedlightshadow;}
.active-column-8 {width: 0px;}
.active-column-9 {width: 0px;}
.active-column-10 {width: 0px;}
.active-column-11{width: 0px;}
.active-column-12 {width: 0px;}
.active-column-13 {width: 0px;}

<!--.active-box-image {height: 16px;} /* for firefox 0.8 */-->

.active-grid-column {border-right: 2px solid threedlightshadow;}
.active-grid-row {border-bottom: 1px solid threedlightshadow;}

.active-templates-row.gecko {
display: -moz-box;
width: auto;
min-width: 100%;
}

.active-row-highlight {background-color: #ddeeff!important}
.active-row-highlight .active-row-cell {background-color: #ddeeff;}

.active-mark-true .active-column-6 {color: #ff0000}

</style>

</head>
<body>
<script>
<!-- grid data -->

var myData = [
["PI00165109/1", "15/06/05", "n/a", "83282", "PC WORLD BUSINESS", "7400153", "49.94", "49.94", "GL1234567890", "HEYWOOD", "MAINTENANCE", "GENERAL REPAIRS", "images/01493492.tif", "P"],
["PI00165501/1", "23/06/05", "n/a", "83282", "PC WORLD BUSINESS", "7421546", "60.31", "60.31", "GL1234567890", "HEYWOOD", "MAINTENANCE", "GENERAL REPAIRS", "images/01493493.tif", "P"],
["PI00166419/1", "11/07/05", "n/a", "83282", "PC WORLD BUSINESS", "7465526", "415.95", "415.95", "GL1234567890", "HEYWOOD", "MAINTENANCE", "GENERAL REPAIRS", "images/01493494.tif", "P"],
["PI00165301/1", "20/06/05", "n/a", "83403", "CURA TECHNICAL", "I/539252", "800.00", "800.00", "GL1234567890", "HEYWOOD", "MAINTENANCE", "GENERAL REPAIRS", "images/01493495.tif", "P"],
["PI00165987/1", "24/06/05", "n/a", "83725", "VODAFONE BUSINESS SOLUTIONS LTD", "2711480", "55.00", "55.00", "GL1234567890", "HEYWOOD", "MAINTENANCE", "GENERAL REPAIRS", "images/01493496.tif", "P"],
["PI00166160/1", "05/07/05", "n/a", "83725", "VODAFONE BUSINESS SOLUTIONS LTD", "2742467", "55.00", "55.00", "GL1234567890", "HEYWOOD", "MAINTENANCE", "GENERAL REPAIRS", "images/01493497.tif", "P"],
["PI00166161/1", "05/07/05", "n/a", "83725", "VODAFONE BUSINESS SOLUTIONS LTD", "2742470", "55.00", "55.00", "GL1234567890", "HEYWOOD", "MAINTENANCE", "GENERAL REPAIRS", "images/01493498.tif", "P"],
["PI00167279/1", "25/07/05", "n/a", "84021", "TELINDUS LTD", "60501625", "850.00", "850.00", "GL1234567890", "HEYWOOD", "MAINTENANCE", "GENERAL REPAIRS", "images/01493499.tif", "C"],
["PI00167838/1", "03/08/05", "n/a", "83975", "SPECTRUM COMPUTER SUPPLIES LTD", "280993", "1,780.20", "1,780.20", "GL1234567890", "HEYWOOD", "MAINTENANCE", "GENERAL REPAIRS", "images/01493500.tif", "P"],
["PI00167842/1", "03/08/05", "n/a", "83282", "PC WORLD BUSINESS", "7524599", "494.95", "494.95", "GL1234567890", "HEYWOOD", "MAINTENANCE", "GENERAL REPAIRS", "images/01493501.tif", "P"],
["PI00167874/1", "05/08/05", "n/a", "83966", "EQUANET LTD", "B260280", "375.00", "375.00", "GL1234567890", "HEYWOOD", "MAINTENANCE", "GENERAL REPAIRS", "images/01493502.tif", "P"],
["PI00167919/1", "30/07/05", "n/a", "83725", "VODAFONE BUSINESS SOLUTIONS LTD", "12790", ".58", ".58", "GL1234567890", "HEYWOOD", "MAINTENANCE", "GENERAL REPAIRS", "images/01493503.tif", "P"],
["PI00169280/1", "31/08/05", "n/a", "83975", "SPECTRUM COMPUTER SUPPLIES LTD", "287099", "28.26", "28.26", "GL1234567890", "HEYWOOD", "MAINTENANCE", "GENERAL REPAIRS", "images/01493504.tif", "P"],
["PI00169306/1", "30/08/05", "n/a", "83282", "PC WORLD BUSINESS", "7584686", "39.43", "39.43", "GL1234567890", "HEYWOOD", "MAINTENANCE", "GENERAL REPAIRS", "images/01493505.tif", "P"],
["PI00169410/1", "31/08/05", "n/a", "80047", "F.H. BROWN LIMITED", "1/1335957", "43.23", "43.23", "GL1234567890", "HEYWOOD", "MAINTENANCE", "GENERAL REPAIRS", "images/01493506.tif", "C"],
["PI00169411/1", "31/08/05", "n/a", "80047", "F.H. BROWN LIMITED", "1/1335956", "34.00", "34.00", "GL1234567890", "HEYWOOD", "MAINTENANCE", "GENERAL REPAIRS", "images/01493507.tif", "P"],
["PI00166160/1", "05/07/05", "n/a", "83725", "VODAFONE BUSINESS SOLUTIONS LTD", "2742467", "55.00", "55.00", "GL1234567890", "HEYWOOD", "MAINTENANCE", "GENERAL REPAIRS", "images/01493508.tif", "P"],
["PI00166161/1", "05/07/05", "n/a", "83725", "VODAFONE BUSINESS SOLUTIONS LTD", "2742470", "55.00", "55.00", "GL1234567890", "HEYWOOD", "MAINTENANCE", "GENERAL REPAIRS", "images/01493509.tif", "P"],
["PI00167279/1", "25/07/05", "n/a", "84021", "TELINDUS LTD", "60501625", "850.00", "850.00", "GL1234567890", "HEYWOOD", "MAINTENANCE", "GENERAL REPAIRS", "images/01493510.tif", "P"],
["PI00167838/1", "03/08/05", "n/a", "83975", "SPECTRUM COMPUTER SUPPLIES LTD", "280993", "1,780.20", "1,780.20", "GL1234567890", "HEYWOOD", "MAINTENANCE", "GENERAL REPAIRS", "images/01493511.tif", "P"],
["PI00167842/1", "03/08/05", "n/a", "83282", "PC WORLD BUSINESS", "7524599", "494.95", "494.95", "GL1234567890", "HEYWOOD", "MAINTENANCE", "GENERAL REPAIRS", "images/01493512.tif", "P"],
["PI00167874/1", "05/08/05", "n/a", "83966", "EQUANET LTD", "B260280", "375.00", "375.00", "GL1234567890", "HEYWOOD", "MAINTENANCE", "GENERAL REPAIRS", "images/01493513.tif", "C"],
["PI00167919/1", "30/07/05", "n/a", "83725", "VODAFONE BUSINESS SOLUTIONS LTD", "12790", ".58", ".58", "GL1234567890", "HEYWOOD", "MAINTENANCE", "GENERAL REPAIRS", "images/01493514.tif", "P"],
["PI00169280/1", "31/08/05", "n/a", "83975", "SPECTRUM COMPUTER SUPPLIES LTD", "287099", "28.26", "28.26", "GL1234567890", "HEYWOOD", "MAINTENANCE", "GENERAL REPAIRS", "images/01493515.tif", "P"],
["PI00169306/1", "30/08/05", "n/a", "83282", "PC WORLD BUSINESS", "7584686", "39.43", "39.43", "GL1234567890", "HEYWOOD", "MAINTENANCE", "GENERAL REPAIRS", "images/01493516.tif", "P"],
["PI00169410/1", "31/08/05", "n/a", "80047", "F.H. BROWN LIMITED", "1/1335957", "43.23", "43.23", "GL1234567890", "HEYWOOD", "MAINTENANCE", "GENERAL REPAIRS", "images/01493517.tif", "P"],
["PI00169411/1", "31/08/05", "n/a", "80047", "F.H. BROWN LIMITED", "1/1335956", "34.00", "34.00", "GL1234567890", "HEYWOOD", "MAINTENANCE", "GENERAL REPAIRS", "images/01493518.tif", "P"]
];

var myColumns = [
"PI Number", "Date", "PO Number", "Account", "Name", "Ref-No", "Inv £", "PO £","","","","","",""
];

// create ActiveWidgets Grid javascript object
var obj = new Active.Controls.Grid;

// set the first column template to image+text
//obj.setColumnTemplate(new Active.Templates.Image, 0);

// set number of rows/columns
obj.setRowProperty("count", 27);
obj.setColumnProperty("count",13);

// provide cells and headers text
obj.setDataProperty("text", function(i, j){return myData[i][j]});
obj.setColumnProperty("text", function(i){return myColumns[i]});

// set column/row headers width/height (0px = not visible)
obj.setColumnHeaderHeight("17px");
obj.setRowHeaderWidth("0px");

// Function controlling the alternating colour of the rows
var alternate = function(){
return this.getProperty("row/order") % 2 ? "#fcfaf6" : "#ffffff";
}

// If Data Column 13 = 'C' (Credit), highlight in red the Invoice Value.
var mark = function(){
var i = this.getProperty("row/index");
return (myData[i][13] == 'C') ? true : false;
}

var row = new Active.Templates.Row;

// Alternate Row Color
row.setStyle("background", alternate);

// Highlight Credits
row.setClass("mark", mark);

// Control Mouse Over / Mouse Out (Row highlighting)
row.setEvent("onmouseover", "mouseover(this, 'active-row-highlight')");
row.setEvent("onmouseout", "mouseout(this, 'active-row-highlight')");
// Write out above 'ROW' actions
obj.setTemplate("row", row);

//add tooltips to the first column template and data model
obj.getColumnTemplate(0).setAttribute("title", function(){return this.getItemProperty("tooltip")});
obj.defineDataProperty("tooltip", function(i, j){return "PI Number : " + myData[i][0] + "\nGL Code : " + myData[i][8] + "\n\nCodes to :\n" + myData[i][9] + "\n" + myData[i][10] + "\n" + myData[i][11]});

// set click action handler
obj.setAction("click",
function()
{
var tiff0;
if(parent.rightFrame.document.getElementById) {
if(parent.rightFrame.document.getElementById('tiffemb0')) {
tiff0=parent.rightFrame.document.getElementById('tiffemb0');
}
else if(parent.rightFrame.document.getElementById('tiffobj0')) {
tiff0=parent.rightFrame.document.getElementById('tiffobj0');
}
}
else if(parent.rightFrame.document.all) {
tiff0=parent.rightFrame.document.all.tiffobj0;
}
var index = this.getSelectionProperty("index");
var imgpath = this.getDataProperty("text", index, 12);
tiff0.LoadImage(imgpath,1,0)
}
);

// write grid html to the page
document.write(obj);

</script>
</body>
</html>
Andy Rush
Wednesday, September 21, 2005

Further clue....

Narrowed the problem down to the code :

var index = this.getSelectionProperty("index");
var imgpath = this.getDataProperty("text", index, 12);

Basically i have a right frame showing an image which needs changing when the user clicks on a row.

To do this i need the image path from the array element 12 in the given row.

The code works, and shows the image fine, however IE status bar shows the previous message.

If i comment out '//' the two lines of the the table works fine (no errors when i click), but the image doesn't load.

Is there a more efficient way of returning the content of a hidden cell on a clicked row than above.

Many thanks

Andy
Andy Rush
Wednesday, September 21, 2005

Fixed it.... thanks for anyone currently looking into this.

For those who are wondering, the change below retrieved the line number for the clicked row, then the contents of a hidden cell in that row.

var rownbr = src.getItemProperty("index");
var imgpath = this.getDataProperty("text", rownbr, 12);


Andy
Andy Rush
Wednesday, September 21, 2005

This topic is archived.


Back to support forum

Forum search