LyndaEngelage Posted February 11, 2019 Share Posted February 11, 2019 I have created a Table as follows. My question is how do I suppress the rows if the data is empty so that the last line moves up under the last record with data. I have a total of 12 possible rows with a total row at the last. The table looks great now but need to purge the empty rows for each record. new FPTable; var table = new FPTable; table.AddColumns(13500,1800,5400); table.AddRows(13); table.Rows[0].Cells[0].Margins = { Top:0, Bottom:68, Left:0, Right:0 }; table.Rows[0].Cells[0].HAlign = "Left"; table.Rows[0].Cells[0].Content=Field("Designation_1"); table.Rows[0].Cells[1].Margins = { Top:0, Bottom:68, Left:0, Right:0 }; table.Rows[0].Cells[1].HAlign = "Center"; table.Rows[0].Cells[1].Content=Field("GC1"); table.Rows[0].Cells[2].Margins = { Top:0, Bottom:68, Left:0, Right:0 }; table.Rows[0].Cells[2].Content=Field("Amount_1"); table.Rows[1].Cells[0].Margins = { Top:0, Bottom:68, Left:0, Right:0 }; table.Rows[1].Cells[0].HAlign = "Left"; table.Rows[1].Cells[0].Content=Field("Designation_2"); table.Rows[1].Cells[1].Margins = { Top:0, Bottom:68, Left:0, Right:0 }; table.Rows[1].Cells[1].HAlign = "Center"; table.Rows[1].Cells[1].Content=Field("GC2"); table.Rows[1].Cells[2].Margins = { Top:0, Bottom:68, Left:0, Right:0 }; table.Rows[1].Cells[2].Content=Field("Amount_2"); table.Rows[2].Cells[0].Margins = { Top:0, Bottom:68, Left:0, Right:0 }; table.Rows[2].Cells[0].HAlign = "Left"; table.Rows[2].Cells[0].Content=Field("Designation_3"); table.Rows[2].Cells[1].Margins = { Top:0, Bottom:68, Left:0, Right:0 }; table.Rows[2].Cells[1].HAlign = "Center"; table.Rows[2].Cells[1].Content=Field("GC3"); table.Rows[2].Cells[2].Margins = { Top:0, Bottom:68, Left:0, Right:0 }; table.Rows[2].Cells[2].Content=Field("Amount_3"); table.Rows[3].Cells[0].Margins = { Top:0, Bottom:68, Left:0, Right:0 }; table.Rows[3].Cells[0].HAlign = "Left"; table.Rows[3].Cells[0].Content=Field("Designation_4"); table.Rows[3].Cells[1].Margins = { Top:0, Bottom:68, Left:0, Right:0 }; table.Rows[3].Cells[1].HAlign = "Center"; table.Rows[3].Cells[1].Content=Field("GC4"); table.Rows[3].Cells[2].Margins = { Top:0, Bottom:68, Left:0, Right:0 }; table.Rows[3].Cells[2].Content=Field("Amount_4"); table.Rows[4].Cells[0].Margins = { Top:0, Bottom:68, Left:0, Right:0 }; table.Rows[4].Cells[0].HAlign = "Left"; table.Rows[4].Cells[0].Content=Field("Designation_5"); table.Rows[4].Cells[1].Margins = { Top:0, Bottom:68, Left:0, Right:0 }; table.Rows[4].Cells[1].HAlign = "Center"; table.Rows[4].Cells[1].Content=Field("GC5"); table.Rows[4].Cells[2].Margins = { Top:0, Bottom:68, Left:0, Right:0 }; table.Rows[4].Cells[2].Content=Field("Amount_5"); table.Rows[5].Cells[0].Margins = { Top:0, Bottom:68, Left:0, Right:0 }; table.Rows[5].Cells[0].HAlign = "Left"; table.Rows[5].Cells[0].Content=Field("Designation_6"); table.Rows[5].Cells[1].Margins = { Top:0, Bottom:68, Left:0, Right:0 }; table.Rows[5].Cells[1].HAlign = "Center"; table.Rows[5].Cells[1].Content=Field("GC6"); table.Rows[5].Cells[2].Margins = { Top:0, Bottom:68, Left:0, Right:0 }; table.Rows[5].Cells[2].Content=Field("Amount_6"); table.Rows[6].Cells[0].Margins = { Top:0, Bottom:68, Left:0, Right:0 }; table.Rows[6].Cells[0].HAlign = "Left"; table.Rows[6].Cells[0].Content=Field("Designation_7"); table.Rows[6].Cells[1].Margins = { Top:0, Bottom:68, Left:0, Right:0 }; table.Rows[6].Cells[1].HAlign = "Center"; table.Rows[6].Cells[1].Content=Field("GC7"); table.Rows[6].Cells[2].Margins = { Top:0, Bottom:68, Left:0, Right:0 }; table.Rows[6].Cells[2].Content=Field("Amount_7"); table.Rows[7].Cells[0].Margins = { Top:0, Bottom:68, Left:0, Right:0 }; table.Rows[7].Cells[0].HAlign = "Left"; table.Rows[7].Cells[0].Content=Field("Designation_8"); table.Rows[7].Cells[1].Margins = { Top:0, Bottom:68, Left:0, Right:0 }; table.Rows[7].Cells[1].HAlign = "Center"; table.Rows[7].Cells[1].Content=Field("GC8"); table.Rows[7].Cells[2].Margins = { Top:0, Bottom:68, Left:0, Right:0 }; table.Rows[7].Cells[2].Content=Field("Amount_8"); table.Rows[8].Cells[0].Margins = { Top:0, Bottom:68, Left:0, Right:0 }; table.Rows[8].Cells[0].HAlign = "Left"; table.Rows[8].Cells[0].Content=Field("Designation_9"); table.Rows[8].Cells[1].Margins = { Top:0, Bottom:68, Left:0, Right:0 }; table.Rows[8].Cells[1].HAlign = "Center"; table.Rows[8].Cells[1].Content=Field("GC9"); table.Rows[8].Cells[2].Margins = { Top:0, Bottom:68, Left:0, Right:0 }; table.Rows[8].Cells[2].Content=Field("Amount_9"); 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"); table.Rows[10].Cells[0].Margins = { Top:0, Bottom:68, Left:0, Right:0 }; table.Rows[10].Cells[0].HAlign = "Left"; table.Rows[10].Cells[0].Content=Field("Designation_11"); table.Rows[10].Cells[1].Margins = { Top:0, Bottom:68, Left:0, Right:0 }; table.Rows[10].Cells[1].HAlign = "Center"; table.Rows[10].Cells[1].Content=Field("GC11"); table.Rows[10].Cells[2].Margins = { Top:0, Bottom:68, Left:0, Right:0 }; table.Rows[10].Cells[2].Content=Field("Amount_11"); table.Rows[11].Cells[0].Margins = { Top:0, Bottom:68, Left:0, Right:0 }; table.Rows[11].Cells[0].HAlign = "Left"; table.Rows[11].Cells[0].Content=Field("Designation_12"); table.Rows[11].Cells[1].Margins = { Top:0, Bottom:68, Left:0, Right:0 }; table.Rows[11].Cells[1].HAlign = "Center"; table.Rows[11].Cells[1].Content=Field("GC12"); table.Rows[11].Cells[2].Margins = { Top:0, Bottom:68, Left:0, Right:0 }; table.Rows[11].Cells[2].Content=Field("Amount_12"); table.Rows[12].Cells[0].Margins = {Top:0, Bottom:68, Left:0, Right:0 }; table.Rows[12].Cells[0].HAlign = "Left"; table.Rows[12].Cells[0].Font = "Brandon Grotesque Bold"; table.Rows[12].Cells[0].Content="TOTAL 2018 TAX-DEDUCTIBLE GIVING:"; table.Rows[12].Cells[2].Margins = { Top:0, Bottom:68, Left:0, Right:0 }; table.Rows[12].Cells[2].HAlign = "Center"; table.Rows[12].Cells[2].Font = "Brandon Grotesque Bold"; table.Rows[12].Cells[2].Content=Field("CAL18_TTL"); return table.MakeTags(); Quote Link to comment Share on other sites More sharing options...
kjacobson Posted February 11, 2019 Share Posted February 11, 2019 Hi LyndaEngelage; If you want to skip a row, you can use the skip type with a condition to check if there is content. 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. 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 Quote Link to comment Share on other sites More sharing options...
LyndaEngelage Posted February 12, 2019 Author Share Posted February 12, 2019 Thank you kjacobson!!! This works perfectly. I wish I know the coding better. Quote Link to comment Share on other sites More sharing options...
LyndaEngelage Posted February 12, 2019 Author Share Posted February 12, 2019 I ran into a snag for this rule, dealing with the ampersand. In the "Designation_"+i fields, the ampersand plus one character gets removed from the data. Example: B&A Scholarship Fund returns as B Scholarship Fund. I know I can use syntax of NormalizeEntities, but I'm not sure where to put it or how. Quote Link to comment Share on other sites More sharing options...
kjacobson Posted February 12, 2019 Share Posted February 12, 2019 You would add the NormalizeEntities() function around the field that you want it applied to: NormalizeEntities(Field("Designation_"+i))The full line would be: tableRow.SetContents(NormalizeEntities(Field("Designation_"+i)),Field("GC"+i),Field("Amount_"+i)); //Add content to the columns Glad to help. You'll learn more JavaScript as you go. Loops, arrays, and functions are great places to start. These aren't just used in FusionPro. This forum and other JavaScript forums have great information if you are willing to search for what you need. Good luck and let me know if you have any other issues with the code. Quote Link to comment Share on other sites More sharing options...
LyndaEngelage Posted February 12, 2019 Author Share Posted February 12, 2019 Yes, this worked great. Sorry for posting on another thread. I didn't know if a second request would be appropriate on an original thread. Again, thank you for all your help! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.