View Single Post
  #2  
Old February 11th, 2019, 03:20 PM
kjacobson's Avatar
kjacobson kjacobson is offline
Regular Contributor
 
Join Date: Oct 2008
Location: Alameda, CA
Posts: 54
Default Re: Suppressing empty rows in a Table

Hi LyndaEngelage;


If you want to skip a row, you can use the skip type with a condition to check if there is content.


Code:
if (Field("Amount_10")=="") {
    table.Rows[9].Type = "Skip";
} else {
    table.Rows[9].Cells[0].Margins = { Top:0, Bottom:68, Left:0, Right:0 };
    table.Rows[9].Cells[0].HAlign = "Left";
    table.Rows[9].Cells[0].Content=Field("Designation_10");
    table.Rows[9].Cells[1].Margins = { Top:0, Bottom:68, Left:0, Right:0 };
    table.Rows[9].Cells[1].HAlign = "Center";
    table.Rows[9].Cells[1].Content=Field("GC10");
    table.Rows[9].Cells[2].Margins = { Top:0, Bottom:68, Left:0, Right:0 };
    table.Rows[9].Cells[2].Content=Field("Amount_10");
}

I've had formatting issue with skipped rows in the past. I have found that it's better to use loops in tables especially when there are sequential fields like you are using.


Code:
new FPTable;
var table = new FPTable;
table.AddColumns(13500,1800,5400);

for (i=1;i<=12;i++) {//Loop through fields
    if (Field("Amount_"+i)!="") {//add a row if the Amount field is not empty
        var tableRow = table.AddRow();  
        tableRow.Cells[0].HAlign = "Left";
        tableRow.Cells[1].HAlign = "Center";
        tableRow.SetContents(Field("Designation_"+i),Field("GC"+i),Field("Amount_"+i)); //Add content to the columns
        for (c=0;c<=2;c++) {//loop through cells to apply margins
            tableRow.Cells[c].Margins = { Top:0, Bottom:68, Left:0, Right:0 };
        }
    }
}

var totalRow = table.AddRow(); //Add total row
totalRow.Cells[0].HAlign = "Left";
totalRow.Cells[2].HAlign = "Center";
totalRow.SetContents("TOTAL 2018 TAX-DEDUCTIBLE GIVING:","",Field("CAL18_TTL")); //Set total row content
for (c=0;c<=2;c++) {//loop through cells to apply margins & font
    totalRow.Cells[c].Margins = { Top:0, Bottom:68, Left:0, Right:0 };
    totalRow.Cells[c].Font = "Brandon Grotesque Bold";
}

return table.MakeTags();

Hope this helps
__________________
Windows 7 | InDesign CC 2017 | Acrobat DC 2019 | FusionPro 11.0.8 | MarcomCentral User
Reply With Quote