Go Back   MarcomCentral (PTI) and FusionPro User Communities > Software-Related Talk > The JavaScript Library > Tables & Charts


Thread Tools Search this Thread Display Modes
Old July 30th, 2019, 03:51 PM
gshaw gshaw is offline
Forum n00b
Join Date: Jan 2011
Location: Gurnee, IL
Posts: 2
Default Suppress empty rows in a table

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.Rows[0].Type = "Header";
table.Rows[0].Cells[0].Bold = "On";
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.
Reply With Quote
Old August 1st, 2019, 06:14 PM
Dan Korn's Avatar
Dan Korn Dan Korn is offline
FusionPro Senior Engineer / Forum Moderator
Join Date: Aug 2008
Location: Chicago, IL
Posts: 4,694
Default Re: Suppress empty rows in a table

Originally Posted by gshaw View Post
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?
Originally Posted by gshaw View Post
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;
var header = table.AddRow();
header.Type = "Header";
header.Cells[0].Bold = "On";
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.
Dan Korn
FusionPro Developer / JavaScript Guru / Forum Moderator
PTI Marketing Technologies | Printable | MarcomCentral

I am a not a Support engineer, and this forum is not a substitute for Support. My participation on this forum is primarily as a fellow user (and a forum moderator). I am happy to provide help and answers to questions when I can; however, there is no guarantee that I, or anyone else on this forum, will be able to answer all questions or fix any problems. If I ask for files to clarify an issue, I might not be able to look at them personally. I am not able to answer private messages, emails, or phone calls unless they go through proper Support channels. Please direct any sales or pricing questions to your salesperson or inquiries@marcom.com.

Complex template-building questions, as well as all installation and font questions or problems, should be directed to FusionProSupport@marcom.com. Paid consulting work may be required to fulfill your template-building needs.

This is a publicly viewable forum. Please DO NOT post fonts, or other proprietary content, to this forum. Also, please DO NOT post any "live" data with real names, addresses, or any other personal, private, or confidential data.

Please include the specific versions of FusionPro, Acrobat, and your operating system in any problem reports or help requests. I recommend putting this information in your forum signature. Please also check your composition log (.msg) file for relevant error or warning messages.

Please post questions specific to the MarcomCentral Enterprise and Web-to-Print applications in the MarcomCentral forum. Click here to request access. Or contact your Business Relationship Manager (BRM/CPM) for assistance.

Please direct any questions specific to EFI's Digital StoreFront (DSF) to EFI support.

How To Ask Questions The Smart Way

The correct spellings are JavaScript, FusionPro, and MarcomCentral (each with two capital letters and no spaces). Acceptable abbreviations are JS, FP, and MC (or MCC). There is no "S" at the end of "Expression" or "Printable"! The name of the product is FusionPro, not "Fusion". "Java" is not is not the same as JavaScript.

Check out the JavaScript Guide and JavaScript Reference! FusionPro 8.0 and newer use JavaScript 1.7. Older versions use JavaScript 1.5.

return "KbwbTdsjqu!spdlt\"".replace(/./g,function(w){return String.fromCharCode(w.charCodeAt()-1)});
Reply With Quote

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

All times are GMT -7. The time now is 05:40 AM.

Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2023, Jelsoft Enterprises Ltd.
(c) 2011, PTI Marketing Technologies™, Inc.