Jump to content
Welcome to the new FusionPro User Forum! ×

Suppress empty rows in a table


gshaw

Recommended Posts

This is my first time creating a table and I am having a problem supressing the empty rows. I read the other post about this issue but the solution in that post would not work for me, I received a message stating "no results".

 

Here is my script:

 

var table = new FPTable;

table.AddColumns(13000,13000,21000);

table.AddRows(35);

table.Rows[0].Type = "Header";

table.Rows[0].Cells[0].Bold = "On";

table.Rows[0].CopyCells(0,1,2);

table.Rows[0].SetContents("Order Number", "Item Number", "Item Description");

table.Rows[1].SetContents(Field("Order#"), Field("Item 1"), Field("Desc 1"));

table.Rows[2].SetContents("", Field("Item 2"), Field("Desc 2"));

table.Rows[3].SetContents("", Field("Item 3"), Field("Desc 3"));

table.Rows[4].SetContents("", Field("Item 4"), Field("Desc 4"));

table.Rows[5].SetContents("", Field("Item 5"), Field("Desc 5"));

table.Rows[6].SetContents("", Field("Item 6"), Field("Desc 6"));

table.Rows[7].SetContents("", Field("Item 7"), Field("Desc 7"));

table.Rows[8].SetContents("", Field("Item 8"), Field("Desc 8"));

table.Rows[9].SetContents("", Field("Item 9"), Field("Desc 10"));

table.Rows[10].SetContents("", Field("Item 9"), Field("Desc 10"));

table.Rows[11].SetContents(Field("Order#2"), Field("Item 1-2"), Field("Desc 1-2"));

table.Rows[12].SetContents("", Field("Item 2-2"), Field("Desc 2-2"));

table.Rows[13].SetContents("", Field("Item 3-2"), Field("Desc 3-2"));

table.Rows[14].SetContents("", Field("Item 4-2"), Field("Desc 4-2"));

table.Rows[15].SetContents("", Field("Item 5-2"), Field("Desc 5-2"));

table.Rows[16].SetContents(Field("Order#3"), Field("Item 1-3"), Field("Desc 1-3"));

table.Rows[17].SetContents("", Field("Item 2-3"), Field("Desc 2-3"));

table.Rows[18].SetContents("", Field("Item 3-3"), Field("Desc 3-3"));

table.Rows[19].SetContents(Field("Order#4"), Field("Item 1-4"), Field("Desc 1-4"));

table.Rows[20].SetContents("", Field("Item 2-4"), Field("Desc 2-4"));

table.Rows[21].SetContents(Field("Order#5"), Field("Item 1-5"), Field("Desc 1-5"));

table.Rows[22].SetContents("", Field("Item 2-5"), Field("Desc 2-5"));

table.Rows[23].SetContents("", Field("Item 3-5"), Field("Desc 3-5"));

table.Rows[24].SetContents("", Field("Item 4-5"), Field("Desc 4-5"));

table.Rows[25].SetContents("", Field("Item 5-5"), Field("Desc 5-5"));

table.Rows[26].SetContents("", Field("Item 6-5"), Field("Desc 6-5"));

table.Rows[27].SetContents(Field("Order#6"), Field("Item 1-6"), Field("Desc 1-6"));

table.Rows[28].SetContents("", Field("Item 2-6"), Field("Desc 2-6"));

table.Rows[29].SetContents("", Field("Item 3-6"), Field("Desc 3-6"));

table.Rows[30].SetContents(Field("Order#7"), Field("Item 1-7"), Field("Desc 1-7"));

table.Rows[31].SetContents(Field("Order#8"), Field("Item 1-8"), Field("Desc 1-8"));

table.Rows[32].SetContents("", Field("Item 2-8"), Field("Desc 2-8"));

table.Rows[33].SetContents("", Field("Item 3-8"), Field("Desc 3-8"));

table.Rows[34].SetContents(Field("Order#9"), Field("Item 1-9"), Field("Desc 1-9"));

return table.MakeTags();

 

Any help would be greatly apprciated.

Link to comment
Share on other sites

This is my first time creating a table and I am having a problem supressing the empty rows. I read the other post about this issue but the solution in that post would not work for me, I received a message stating "no results".

What do you mean you "received a message?" Was this a message in the composition log (.msg) file from the FusionPro composition? Or did you see that message somewhere else?

Here is my script:

I can't really do much with that code, without what would seem to be your fairly complex data file that has all those data fields in it. Having that, or even better, the collected template, would make it easier to reproduce what you're seeing and offer specific suggestions.

 

I will say, though, that a couple of "for" loops would greatly reduce the repetitiveness of the code, and make it a bit more obvious how to simply not output rows with empty data. Something like this:

var table = new FPTable;
table.AddColumns(13000,13000,21000);
var header = table.AddRow();
header.Type = "Header";
header.Cells[0].Bold = "On";
header.CopyCells(0,1,2);
header.SetContents("Order Number", "Item Number", "Item Description");

for (var order = 1; order <= 9; order++)
{
   var orderText = Field("Order#" + (order == 1 ? "" : order));
   for (var item = 1; item <= 9; item++)
   {
       var itemNum = (order == 1) ? "" : order + "-";
       itemNum += item;

       if (!Field("Item " + itemNum) || !Field("Desc " + itemNum))
           continue; // skip empty rows

       var row = table.AddRow();
       row.SetContents(orderText, Field("Item " + itemNum), Field("Desc " + itemNum));
       orderText = ""; // show on first row of each order only
  }
}
return table.MakeTags();

Again, though, this is a shot in the dark without having the data file.

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