Kal Posted December 10, 2015 Share Posted December 10, 2015 Hi, I need to suppress lines when empty in a table and don't know what I need to add for it to work. See sample table rule. ------------------------------------------------ new FPTable; var myTable = new FPTable; myTable.AddColumns(36000, 14400); myTable.AddRows(5); //Line1 myTable.Rows[0].Cells[0].Content = "Account Line"; myTable.Rows[0].Cells[1].Content = Field("PD_PRINCIPAL1"); //Line2 myTable.Rows[1].Cells[0].Content = Field("PD_TOTAL3"); myTable.Rows[1].Cells[1].Content = Field("PD_PRINCIPAL3"); //Line3 myTable.Rows[2].Cells[0].Content = Field("PD_TOTAL2"); myTable.Rows[2].Cells[1].Content = Field("PD_PRINCIPAL2"); return myTable.MakeTags(); Quote Link to comment Share on other sites More sharing options...
Dan Korn Posted December 10, 2015 Share Posted December 10, 2015 I think it's better to think less in terms of suppressing empty rows (lines), and more in terms of adding rows only when they have content, like so: var myTable = new FPTable; myTable.AddColumns(36000, 14400); //Line1 var myRow = myTable.AddRow(); myRow.Cells[0].Content = "Account Line"; myRow.Cells[1].Content = Field("PD_PRINCIPAL1"); //Line2 if (Field("PD_TOTAL3") && Field("PD_PRINCIPAL3")) { var myRow = myTable.AddRow(); myRow.Cells[0].Content = Field("PD_TOTAL3"); myRow.Cells[1].Content = Field("PD_PRINCIPAL3"); } //Line3 if (Field("PD_TOTAL2") && Field("PD_PRINCIPAL2")) { var myRow = myTable.AddRow(); myRow.Cells[0].Content = Field("PD_TOTAL2"); myRow.Cells[1].Content = Field("PD_PRINCIPAL2"); } return myTable.MakeTags(); Or somewhat more succinctly: var myTable = new FPTable; myTable.AddColumns(36000, 14400); //Line1 myTable.AddRow().SetContents( "Account Line", Field("PD_PRINCIPAL1")); //Line2 if (Field("PD_TOTAL3") && Field("PD_PRINCIPAL3")) myTable.AddRow().SetContents(Field("PD_TOTAL3"), Field("PD_PRINCIPAL3")); //Line3 if (Field("PD_TOTAL2") && Field("PD_PRINCIPAL2")) myTable.AddRow().SetContents(Field("PD_TOTAL2"), Field("PD_PRINCIPAL2")); return myTable.MakeTags(); Or, more generally: var myTable = new FPTable; myTable.AddColumns(36000, 14400); for (var i = 1; i <= 3; i++) { var cell0Content = i == 1 ? "Account Line" : Field("PD_TOTAL" + i); var cell1Content = Field("PD_PRINCIPAL" + i); if (cell0Content && cell1Content) myTable.AddRow().SetContents(cell0Content, cell1Content); } return myTable.MakeTags(); Quote Link to comment Share on other sites More sharing options...
Kal Posted December 10, 2015 Author Share Posted December 10, 2015 Thank you Dan. You just made my day. Quote Link to comment Share on other sites More sharing options...
Kal Posted December 11, 2015 Author Share Posted December 11, 2015 Is there a way to make the top line like 7inch long without effecting then lines below? ----- var myTable = new FPTable; myTable.AddColumns(36000, 14400); //Line0 var myRow = myTable.AddRow(); myRow.Cells[0].Content = "Account Info Area1"; myTable.Rows[0].Cells[0].TextColor="White"; myTable.Rows[0].Cells[0].ShadeColor="Black"; myTable.Rows[0].Cells[0].ShadePct=50; //Line1 var myRow = myTable.AddRow(); myRow.Cells[0].Content = "Account Line"; myRow.Cells[1].Content = Field("PD_PRINCIPAL1"); //Line2 if (Field("PD_TOTAL3") && Field("PD_PRINCIPAL3")) { var myRow = myTable.AddRow(); myRow.Cells[0].Content = Field("PD_TOTAL3"); myRow.Cells[1].Content = Field("PD_PRINCIPAL3"); } //Line3 if (Field("PD_TOTAL2") && Field("PD_PRINCIPAL2")) { var myRow = myTable.AddRow(); myRow.Cells[0].Content = Field("PD_TOTAL2"); myRow.Cells[1].Content = Field("PD_PRINCIPAL2"); } return myTable.MakeTags(); Quote Link to comment Share on other sites More sharing options...
Dan Korn Posted December 11, 2015 Share Posted December 11, 2015 Is there a way to make the top line like 7inch long without effecting then lines below? Sure, just make that top line into a completely separate single-row table. Quote Link to comment Share on other sites More sharing options...
Dan Korn Posted December 11, 2015 Share Posted December 11, 2015 Sure, just make that top line into a completely separate single-row table. Or, add another column, and only set its contents and shading and such in the first row. 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.