Jump to content

Variable Table Rows based on External Data


dfalkowitz

Recommended Posts

Do you have any templates or examples that show how to have variable table rows?

For Example: I need to build a table that can have anywhere from 1-50 rows based off of a External file. I only want to show the amount of rows for each record. Record 1 will have 3 rows but Record 2 might have 5 rows. Anything you have will be appreciated. Thanks!

Link to comment
Share on other sites

The Frodo Travel tutorial has a couple of examples of variable tables built from external data. Note that, although the main itinerary table in that job is built in the OnRecordStart rule, that's just a peculiarity that job; you can build the whole table in a regular rule.
Link to comment
Share on other sites

Dan - How would this work if I needed to add a new row to the table on the fly based the external file.

 

Reference to the Frodo Travel tutorial - Right now on the external file "Intinerary.txt" each location only has one row, what if each location had different amount of rows?

Link to comment
Share on other sites

Dan - How would this work if I needed to add a new row to the table on the fly based the external file.

 

Reference to the Frodo Travel tutorial - Right now on the external file "Intinerary.txt" each location only has one row, what if each location had different amount of rows?

Just call the AddRows function to add rows as you need them, or append a new <row> tag if you're building up the markup the old way.

Link to comment
Share on other sites

Where would I add the call to AddRows (rule below):

 

if(FusionPro.inValidation)

Rule("OnJobStart");

 

var DaysOfWeek = ["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"];

 

 

text = new FPTable; //This variable is defined in the Globals dialog.

text.AddColumns(8000, 8000, 8000, 8000, 8000, 8000, 8000);

text.AddRows(3);

 

for(a=0;a<7;a++) //Loops through the cells in a row

{

//Row 1

text.Rows[0].Cells[a].Content = DaysOfWeek[a];

cellTraits(0,a); //Calls the function defined below to set the cell borders and margins

 

//Row 2

x = data.FindRecord("Location", Trim(Field("Destination")))

text.Rows[1].Cells[a].Content = "<z newsize=14>" + (a+17) + "<z newsize=9><br>" + Trim(data.GetFieldValue(x, a+1));

cellTraits(1,a);

 

//Row 3

var value = Trim(data.GetFieldValue(x, a+8));

if(value != "")

{

text.Rows[2].Cells[a].Content = "<z newsize=14>" + (a+24) + "<z newsize=9><br>" + value;

cellTraits(2,a);

}

}

 

text = text.MakeTags();

text = "Dates and Times During your Trip<br><z newsize=2> <z newsize=10><br>" + text;

 

 

function cellTraits(b,a)

{

text.Rows.Cells[a].SetBorders("Thin", "Black", "Top", "Bottom", "Left", "Right");

text.Rows.Cells[a].Margins = new FPTableMargins;

text.Rows.Cells[a].Margins.Top = 60;

text.Rows.Cells[a].Margins.Bottom = 40;

text.Rows.Cells[a].Margins.Left = 600;

text.Rows.Cells[a].Margins.Right = 600;

}

Link to comment
Share on other sites

Where would I add the call to AddRows (rule below):

Well, I don't know exactly what your data looks like or how you want to present it in a table, so I doubt you would be using that exact code, but you could call text.AddRows anywhere between "text = new FPTable" and "text = text.MakeTags()".

 

Basically, you declare a new FPTable object, call AddColumns, then call AddRows as many times as necessary, setting the cell contents with the Rows and Cells properties. When you're all done, you call MakeTags to get the markup to return from the rule which creates the table in your output.

 

Take a look at this example:

http://forums.printable.com/showpost.php?p=6619&postcount=4

Link to comment
Share on other sites

  • 3 months later...
  • 2 weeks later...
Where can I find the Frodo Travel tutorial?

For FusionPro 7.2, there's a Tutorial folder under the main folder where you installed FusionPro. By default, on Mac, it's "/Applications/Printable/FusionPro/Tutorial", and on Windows, it's "C:\Program Files\Printable\FusionPro\Tutorial".

 

For FusionPro 8, you can use the menu item in Acrobat, "FusionPro -> Documentation -> Tutorials" to open the Tutorials folder.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...