Jump to content

Make a table with formatted text that flows below


lasdoog

Recommended Posts

Hello,

 

 

I"m new to working with tables in FusionPro and I have a problem I can't resolve. Part of the job I'm working on has a table with anywhere from 1 to 8 possible rows, then 4 rows of totals flush right. There is also formatted text below this that must move with the table size (1 to 8 rows).

 

 

I've been able to handle the first 8 rows by altering a SteP script from the forum which surpresses a row based on a field, but I can't get past these 8 rows.

 

 

 

Here's where my script is at:

 

 

var fields = [[Field("Plan/Item 1 Name"), Field("Plan/Item 1 QTY"), Field("Plan/Item 1 Sec"), Field("Plan/Item 1 Row"), Field("Plan/Item 1 Block"), "$"+ Field("Plan/Item 1 Per"), "$"+ Field("Plan/Item 1 Total")],

[Field("Plan/Item 2 Name"), Field("Plan/Item 2 QTY"), Field("Plan/Item 2 Sec"), Field("Plan/Item 2 Row"), Field("Plan/Item 2 Block"), "$"+ Field("Plan/Item 2 Per"), "$"+ Field("Plan/Item 2 Total")],

[Field("Plan/Item 3 Name"), Field("Plan/Item 3 QTY"), Field("Plan/Item 3 Sec"), Field("Plan/Item 3 Row"), Field("Plan/Item 3 Block"), "$"+ Field("Plan/Item 3 Per"), "$"+ Field("Plan/Item 3 Total")],

[Field("Plan/Item 4 Name"), Field("Plan/Item 4 QTY"), Field("Plan/Item 4 Sec"), Field("Plan/Item 4 Row"), Field("Plan/Item 4 Block"), "$"+ Field("Plan/Item 4 Per"), "$"+ Field("Plan/Item 4 Total")],

[Field("Plan/Item 5 Name"), Field("Plan/Item 5 QTY"), Field("Plan/Item 5 Sec"), Field("Plan/Item 5 Row"), Field("Plan/Item 5 Block"), "$"+ Field("Plan/Item 5 Per"), "$"+ Field("Plan/Item 5 Total")],

[Field("Plan/Item 6 Name"), Field("Plan/Item 6 QTY"), Field("Plan/Item 6 Sec"), Field("Plan/Item 6 Row"), Field("Plan/Item 6 Block"), "$"+ Field("Plan/Item 6 Per"), "$"+ Field("Plan/Item 6 Total")],

[Field("Plan/Item 7 Name"), Field("Plan/Item 7 QTY"), Field("Plan/Item 7 Sec"), Field("Plan/Item 7 Row"), Field("Plan/Item 7 Block"), "$"+ Field("Plan/Item 7 Per"), "$"+ Field("Plan/Item 7 Total")],

[Field("Plan/Item 8 Name"), Field("Plan/Item 8 QTY"), Field("Plan/Item 8 Sec"), Field("Plan/Item 8 Row"), Field("Plan/Item 8 Block"), "$"+ Field("Plan/Item 8 Per"), "$"+ Field("Plan/Item 8 Total")],

]

 

var myTable = new FPTable;

myTable.AddColumns(19400, 4300, 4500, 4500, 8200, 7200, 6000);

myTable.AddRows(9);

 

for (var i=0; i<9; i++) {

if (fields[2] != "NULL") {

//myTable.Rows.Cells[0].SetBorders("Thin","Black","Top","Bottom","Right","Left");

myTable.Rows.CopyCells(0,1,2,3,4,5,6);

myTable.Rows.Cells[0].HAlign = "Left";

myTable.Rows.SetContents(fields[0], fields[1], fields[2], fields[3], fields[4], fields[5], fields[6]);

}

}

 

return myTable.MakeTags();

 

 

_____________________________________________________________

 

I've made a formatted text resource and added it after the table, but it still sees the table as 8 rows even if they aren't visible.

 

 

Please see attached screenshot for clarity

 

 

 

Any suggestions are greatly appreciated!

 

 

 

 

 

___________________________________________

MAC OS 10.13.6, FusionPro 10.1.11, Acrobat 11.0.23

VariableTablewithtextbelow.png.eef59a59cf78f97298fadf697d921ca6.png

Link to comment
Share on other sites

Well, you're unconditionally adding 9 rows to the table with "myTable.AddRows(9)". You're not actually suppressing any rows at all; you're just inserting empty rows. So yeah, you'll always get 9 rows with that code.

 

The solution is to call AddRow() once per row, as needed (i.e. only when you actually need a new row). Also, the first part of your rule, which is very repetitive, screams out for a "for" loop, though I would just use the same "for" loop you already have.

 

I don't have the rest of your template to try, but I think this will work:

var myTable = new FPTable;
myTable.AddColumns(19400, 4300, 4500, 4500, 8200, 7200, 6000);

for (var i = 1; i <= 8; i++)
{
   if (Field("Plan/Item " + i + " Sec") == "NULL")
       continue; // skip this row

   var row = myTable.AddRow();
   //row.Cells[0].SetBorders("Thin", "Black", "Top", "Bottom", "Right", "Left");
   row.Cells[0].HAlign = "Left";
   row.CopyCells(0,1,2,3,4,5,6);
   row.SetContents(Field("Plan/Item " + i + " Name"),
                   Field("Plan/Item " + i + " QTY"),
                   Field("Plan/Item " + i + " Sec"),
                   Field("Plan/Item " + i + " Row"),
                   Field("Plan/Item " + i + " Block"),
                   "$"+ Field("Plan/Item " + i + " Per"),
                   "$"+ Field("Plan/Item " + i + " Total"));
}

return myTable.MakeTags();

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...