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()...
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));
}
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));
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()...
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()...
This topic is archived.