Jump to content

Suppress empty lines in Table


Kal

Recommended Posts

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

 

 

 

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

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...