Hi,
I have an array of data that I want to pass from a button to a function to create a table.
I just started using LiveCycle two hours ago.
I am very good with JavaScript and Acrobat.
But this has me stumped.
I found a page with a function, but it takes JSON and so I'm trying to decode it to use an array and allong the lines it's getting stopped up and I'm getting this error
GeneralError: Operation failed.
XFAObject._Row:33:XFA:form1[0]:#subform[0]:Button1[0]:click
Invalid property get operation; subform doesn't have property '_Row'
Here's the page I found
http://blogs.adobe.com/acdc/2009/02/dynamically_creating_a_table_w.htm l
and here's the code that I have modified.
form1.#variables[0].createTable - (JavaScript, client)
/**
* Create rows and columns based on the number of data items and number of attributes
*/
function createTable(product, table)
{
// Evaluate JSON string into a array of JavaScript objects
// See the StringSO script object for the prototype function
//var data = jsonString.evalJSON();
//var attributes = new Array();
//var attributeCounter = 0;
var row = table.somExpression + ".Row";
var pageWidth = 8; // inches;
var cellWidth;
var columnWidthsString = "";
// Get all attributes
/*
for(var a in data[0])
{
attributes[attributeCounter++] = a;
}
*/
// Calculate the cell width based on number of columns and page width
cellWidth = .5 //pageWidth/attributes.length;
// Create first column for all rows
for(i = 0; i < 10; i++)//consider. product.length, was data.length
{
table._Row.addInstance(0);
}
// creating columns
for(i = 0; i < attributes.length; i++)
{
for(var n = 0; n <= data.length; n++)
{
var column = row + "[" + n + "].Column[" + i + "]";
var cell = column + ".Cell";
// Set the value in the cell
if(n == 0)
{
xfa.resolveNode(cell).rawValue = attributes[i];
}
else
{
xfa.resolveNode(cell).rawValue = data[n-1][attributes[i]] + "";
}
if(i < attributes.length - 1)
{
var t = row + "[" + n + "]";
xfa.resolveNode(t)._Column.addInstance(0);
}
// Set cell width
xfa.resolveNode(cell).w = cellWidth + "in";
}
// Building column widths string
columnWidthsString += cellWidth + "in ";
}
// Set column widths
table.columnWidths = columnWidthsString;
// Make the table visible
table.presence = "visible";
}
I basically started commenting stuff out to figure out what does what and I was going to let the errors in the console show me the way, but I'm stuck on _Row. It's throwing an error, even though this looks like a built in property.
So I'm thinking maybe I set up my table and form wrong from the start.
If anyone has a way to do this that doesn't involve scripting I'd be open to that as well. Thanks.