MarcomCentral (PTI) and FusionPro User Communities

MarcomCentral (PTI) and FusionPro User Communities (http://forums.pti.com/index.php)
-   Getting Started (http://forums.pti.com/forumdisplay.php?f=18)
-   -   Make a table with formatted text that flows below (http://forums.pti.com/showthread.php?t=5415)

lasdoog October 25th, 2019 04:27 PM

Make a table with formatted text that flows below
 
1 Attachment(s)
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[i][2] != "NULL") {
//myTable.Rows[i].Cells[0].SetBorders("Thin","Black","Top","Bottom","Right", "Left");
myTable.Rows[i].CopyCells(0,1,2,3,4,5,6);
myTable.Rows[i].Cells[0].HAlign = "Left";
myTable.Rows[i].SetContents(fields[i][0], fields[i][1], fields[i][2], fields[i][3], fields[i][4], fields[i][5], fields[i][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

Dan Korn October 28th, 2019 10:49 AM

Re: Make a table with formatted text that flows below
 
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:
Code:

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();


lasdoog October 28th, 2019 03:33 PM

Re: Make a table with formatted text that flows below
 
Thanks Dan!


All times are GMT -7. The time now is 11:47 PM.

Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
(c) 2011, PTI Marketing Technologies™, Inc.