:: Forum >>

cell bug?

Hello,
When I try to get the value of a particular cell I get an error that says: Error: this._rows[r] has no properties

I don't think this is my doing but I could just be calling the wrong things. I know the grid is correct, and there is data because the first thing I do is display the grid. Before I get to the code, what I am doing here is uploading a CSV file, displaying the grid, then I am trying to pop up the data in 0,0. to see the data I am using the obj.getCellValue(0,0); function. Any ideas on how to fix this?

this gets the CSV file...
function csvGenerate(gridData) {
/*
gridData - javascript object used to hold data needed by csvGenerate
gridData.headers - Holds all the header names
gridData.cols - Number of columns shown by the grid
gridData.css - cssAssociated with this particular grid
gridData.file - name of the CSV file
gridData.location - associated with the ID where the grid is supposed to be placed on the page
*/

var csvData = new AW.CSV.Table;

csvData.setProperty("URL", gridData.file);
csvData.request();

var obj = new AW.UI.Grid; //global grid object
obj.setColumnCount(gridData.cols);
obj.setCellModel(csvData);
obj.setId(gridData.css);
obj.setHeaderText(gridData.headers);

return obj;

}//csvGenerate()...


this opens the obj file, displays to screen then pops the data in 0,0
function validateData () {
var fileName = GLOBAL_UI_DIRECTORY+"test.txt";
alert (fileName);

var obj = csvGenerate(
{
headers: ["Last Name", "First Name", "Email Address", "Cell Number", "User Profile"],
cols: 5,
css: "myGrid",
file: fileName,
location: "gridBody"
}
);

var i = 0;

var test = $("gridBody");
test.innerHTML = obj;

alert (obj.getCellValue(0,0));
}


Help! thanks!
Joe C
Monday, May 8, 2006
oh...that test.txt file has 2 rows and 5 cols of data....and it does pop up the grid so it is getting the data correctly at that point
Joe C
Monday, May 8, 2006
OK....if I make my function look like this....i actually get data and not an error...
function validateData () {
var fileName = GLOBAL_UI_DIRECTORY+"test.txt";
alert (fileName);

var obj = csvGenerate(
{
headers: ["Last Name", "First Name", "Email Address", "Cell Number", "User Profile"],
cols: 5,
css: "myGrid",
file: fileName,
location: "gridBody"
}
);

var i = 0;

var test = $("gridBody");
test.innerHTML = obj;
alert ("ready to pop....");
alert (obj.getCellValue(0,0));


hmm....any ideas on this one?
Joe C
Monday, May 8, 2006
Ok, so the problem is more general then just popping things up. Take a look at this code here:
function validateData () {
var fileName = GLOBAL_UI_DIRECTORY+"test.txt";
var url = GLOBAL_SERVICES_URL+"addLpUser.php";

var obj = csvGenerate(
{
headers: ["Last Name", "First Name", "Email Address", "Cell Number", "User Profile"],
cols: 5,
css: "myGrid",
file: fileName,
location: "gridBody"
}
);

var test = $("gridBody");
var showLoc = $("saveButton");
Element.show(showLoc);
test.innerHTML = obj;

var errCounter = -1;
var error = new Array();
alert ("NEEDED TO GET NEWEST DATA");
for (var i = 0; i < obj.getRowCount(); i++) {
var last = obj.getCellValue(0,i);
var first = obj.getCellValue(1,i);
var email = obj.getCellValue(2,i);
var cell = obj.getCellValue(3,i);
var phone = obj.getCellValue(4,i);
var params = "firstName="+first+"&lastName="+last+"&emailAddress"+email+"&cell="+cell+"&phone="+phone+"&validate=yes";

var myAjax = new Ajax.Request (
url,
{
method:"get",
parameters: params,
asynchronous: false
}
);
var transport = myAjax.transport;
var respXML = transport.responseXML;
var status = getXMLStatus (respXML.getElementsByTagName("x"));

if (status[0] == 1) {
var message = "Line number "+(i+1)+" error: "+status[1]+"<br/>";
error[++errCounter] = message;
}//if...

}//for...

if (errCounter >= 0) {
alert ("Your Document Cannot be saved you have errors!");
for (var i = 0; i <= errCounter; i++) {
document.write(error[i]);
}//for...
}//if...
else {
alert ("Data ready for saving");
}

}//validateData()...


If I take that alert box OUT of my code....it doesn't work....at all
Joe C
Monday, May 8, 2006
Joe,

this looks like a timing problem - you are trying to get cell value before the request had arrived. If you add

csvData.setAsync(false);

it should work.
Alex (ActiveWidgets)
Monday, May 8, 2006
Hey Alex,
Nope...still the same problem. Here is the updated code I am working with:
function csvGenerate(gridData) {
/*
gridData - javascript object used to hold data needed by csvGenerate
gridData.headers - Holds all the header names
gridData.cols - Number of columns shown by the grid
gridData.css - cssAssociated with this particular grid
gridData.file - name of the CSV file
gridData.location - associated with the ID where the grid is supposed to be placed on the page
*/

var csvData = new AW.CSV.Table;

csvData.setProperty("URL", gridData.file);

csvData.request();
csvData.setAsync(false);

var obj = new AW.UI.Grid;
obj.setColumnCount(gridData.cols);
obj.setCellModel(csvData);
obj.setId(gridData.css);
obj.setHeaderText(gridData.headers);

return obj;

}//csvGenerate()...

function validateData () {
var fileName = GLOBAL_UI_DIRECTORY+"test.txt";
var url = GLOBAL_SERVICES_URL+"addLpUser.php";

var obj = csvGenerate(
{
headers: ["Last Name", "First Name", "Email Address", "Cell Number", "User Profile"],
cols: 5,
css: "myGrid",
file: fileName,
location: "gridBody"
}
);

var test = $("gridBody");
var svbttn = "<input type='button' onclick='saveData();' value='Save this File'/><br/><br/>"
test.innerHTML =svbttn+ obj;

var errCounter = -1;
var error = new Array();
alert ("STILL NEEDED");
for (var i = 0; i < obj.getRowCount(); i++) {
var last = obj.getCellValue(0,i);
var first = obj.getCellValue(1,i);
var email = obj.getCellValue(2,i);
var cell = obj.getCellValue(3,i);
var phone = obj.getCellValue(4,i);
var params = "firstName="+first+"&lastName="+last+"&emailAddress="+email+"&cell="+cell+"&phone="+phone+"&validate=yes";

var myAjax = new Ajax.Request (
url,
{
method:"get",
parameters: params,
asynchronous: false
}
);
var transport = myAjax.transport;
var respXML = transport.responseXML;
var status = getXMLStatus (respXML.getElementsByTagName("x"));

if (status[0] == 1) {
var message = "Line number "+(i+1)+" error: "+status[1]+"<br/>";
error[++errCounter] = message;
}//if...

}//for...

if (errCounter >= 0) {
alert ("Your Document Cannot be saved you have errors!");
for (var i = 0; i <= errCounter; i++) {
document.write(error[i]);
}//for...
}//if...

}//validateData()...

Thanks for your help with this
Joe C
Monday, May 8, 2006
Try calling setAsync(false) before request()
Alex (ActiveWidgets)
Monday, May 8, 2006
If I put the setAsync before the request no data comes up. It builds the grid and fills it with blank data. For the XMLHTTPRequest I am using prototype.js....do you think there could be some strange interaction between AW and Prototype? I am going to switch over to a pure AW request and see if that fixes anything.
Joe C
Tuesday, May 9, 2006
<META HTTP-EQUIV="Pragma" CONTENT="no-cache"> this fixed it...AW was looking at cached pages for some reason. So I put this in my HTML and it gets the newest dataset every time I make a change. I don't know if this is the BEST fix for it but it works so I am happy with it. Thanks Alex for your help with this.
Joe C
Tuesday, May 9, 2006

This topic is archived.


Back to support forum

Forum search