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

Notices

Reply
 
Thread Tools Search this Thread Display Modes
  #21  
Old April 3rd, 2012, 05:05 PM
AndyShaw AndyShaw is offline
Forum n00b
 
Join Date: Oct 2008
Posts: 6
Default Re: JavaScript Table API – The Basics

How would I use the API to set table attributes for the whole table, rather than cell by cell? Having to specify everything for every cell is rather tedious. Specifically, I want to set the margins and rules for the entire table, if that is possible, rather than doing it all cell by cell.

Thanks, Andy

P.S. I am using FusionPro 7.2P1k but am about to move up to FP 8.0.
__________________
Andy Shaw, Director
Digital Print Technology
Nimblefish Technologies
Reply With Quote
  #22  
Old April 4th, 2012, 09:37 AM
Dan Korn's Avatar
Dan Korn Dan Korn is offline
FusionPro Senior Engineer / Forum Moderator
 
Join Date: Aug 2008
Location: Chicago, IL
Posts: 4,322
Default Re: JavaScript Table API – The Basics

Quote:
Originally Posted by AndyShaw View Post
How would I use the API to set table attributes for the whole table, rather than cell by cell? Having to specify everything for every cell is rather tedious. Specifically, I want to set the margins and rules for the entire table, if that is possible, rather than doing it all cell by cell.
You can iterate through the cells and set whatever attributes you want, as in this example. Also take a look at the Money Table rule in the Frodo Travel tutorial.
__________________
Dan Korn
FusionPro Developer / JavaScript Guru / Forum Moderator
PTI Marketing Technologies | Printable | MarcomCentral
LinkedIn

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
  #23  
Old April 4th, 2012, 09:52 AM
AndyShaw AndyShaw is offline
Forum n00b
 
Join Date: Oct 2008
Posts: 6
Default Re: JavaScript Table API – The Basics

Thanks, Dan, that will point me in the right direction. Javascript is not my strong suit.

Andy
__________________
Andy Shaw, Director
Digital Print Technology
Nimblefish Technologies
Reply With Quote
  #24  
Old January 2nd, 2013, 03:40 PM
-Lisa- -Lisa- is offline
Senior Contributor
 
Join Date: Sep 2008
Location: Long Island, NY
Posts: 189
Default Re: JavaScript Table API – The Basics

Dan,

Happy New Year.

I stumbled upon this posting while researching dynamic tables. This is great, thank you! However when I try building my rule, I receive the following error:

"\Library\Application Support/Printable/FusionPro/Builtins.js, line 3252: TypeError: this.Cells[arguments[i]] has no properties"

Based on your original post, this should work in Version 7 and I'm running 7.2P1k on Mac OS X so I can't seem to figure out what's causing this?
Reply With Quote
  #25  
Old January 2nd, 2013, 03:54 PM
step's Avatar
step step is offline
Senior Contributor
 
Join Date: Jan 2010
Location: Charlotte, NC
Posts: 955
Default Re: JavaScript Table API – The Basics

Lisa, my first thought is that you haven't specified what row the cell you're wanting to apply the arguments to.

That being said, would you mind posting the block of code where you're building your table so that we could get a better idea?
__________________
Ste Pennell
FusionPro VDP Creator 9.3.15
Adobe Acrobat X 10.1.1
Mac OS X 10.12

LinkedIn

Last edited by step; January 2nd, 2013 at 04:06 PM..
Reply With Quote
  #26  
Old January 3rd, 2013, 06:08 AM
dreimer dreimer is offline
Senior Contributor
 
Join Date: Oct 2010
Location: Shakopee, MN
Posts: 465
Default Re: JavaScript Table API – The Basics

Quick question with tables. When I validate my rule, there is a (truncated to 10000 characters) warning. Is this for the validation process or for the table itself?
__________________
Don Reimer - JavaScript Novice

MAC OS 10.12.5 Acrobat XI 11.0.0 FP Creator 10.0.16
Windows 7 Acrobat X 10.1.4 FP Creator 9.3.9
Reply With Quote
Old January 3rd, 2013, 06:50 AM
-Lisa-
This message has been deleted by -Lisa-. Reason: Added reply incorrectly
  #27  
Old January 3rd, 2013, 06:52 AM
-Lisa- -Lisa- is offline
Senior Contributor
 
Join Date: Sep 2008
Location: Long Island, NY
Posts: 189
Default Re: JavaScript Table API – The Basics

Ste,

Thanks for the reply. You were correct in your assumption and I was able to resolve the validation issue. However now when I insert the rule into a text frame, all I see is the black shading from the first column. No other data is populating. Here's the code I'm using

Code:
new FPTable; 
var myTable = new FPTable
myTable.AddColumns(17000, 8107);
myTable.AddRows(6); 
myTable.Rows[0].Cells[0].Font="Times New Roman"; 
myTable.Rows[0].Cells[0].TextColor="White";
myTable.Rows[0].Cells[0].ShadeColor="Black"; 
myTable.Rows[0].Cells[0].ShadePct=100;
myTable.Rows[1].Cells[0].Font="Times New Roman"; 
myTable.Rows[1].Cells[0].TextColor="Black";
myTable.Rows[1].Cells[0].ShadeColor="White"; 
myTable.Rows[1].Cells[0].ShadePct=100;
myTable.Rows[1].CopyCells(0,1);

myTable.Rows[2].Cells[0].Font="Times New Roman"; 
myTable.Rows[2].Cells[0].TextColor="Black";
myTable.Rows[2].Cells[0].ShadeColor="White"; 
myTable.Rows[2].Cells[0].ShadePct=100;
myTable.Rows[2].CopyCells(0,1);
myTable.Rows[3].Cells[0].Font="Times New Roman"; 
myTable.Rows[3].Cells[0].TextColor="Black";
myTable.Rows[3].Cells[0].ShadeColor="White"; 
myTable.Rows[3].Cells[0].ShadePct=100;
myTable.Rows[3].CopyCells(0,1);
myTable.Rows[4].Cells[0].Font="Times New Roman"; 
myTable.Rows[4].Cells[0].TextColor="Black";
myTable.Rows[4].Cells[0].ShadeColor="White"; 
myTable.Rows[4].Cells[0].ShadePct=100;
myTable.Rows[4].CopyCells(0,1);
myTable.Rows[5].Cells[0].Font="Times New Roman"; 
myTable.Rows[5].Cells[0].TextColor="Black";
myTable.Rows[5].Cells[0].ShadeColor="White"; 
myTable.Rows[5].Cells[0].ShadePct=100;
myTable.Rows[5].CopyCells(0,1);

myTable.Rows[0].SetContents = ("Earnings", 'Company Paid");
myTable.Rows[1].SetContents = ("Shift Differential Pay Overtime", Field("ShiftDifferenceOT"));
myTable.Rows[2].SetContents = ("Shift Differential Pay", Field("ShiftDifference"));
myTable.Rows[3].SetContents = ("Overtime Pay", Field("OTPay"));
myTable.Rows[4].SetContents = ("Regular Earnings", Field("RegEarnings"));
myTable.Rows[5].SetContents = ("Gross Earnings", Field("GrossEarnings"));
return myTable.MakeTags();
Any thoughts as to what I'm missing here?

Thanks!
Reply With Quote
  #28  
Old January 3rd, 2013, 09:20 AM
step's Avatar
step step is offline
Senior Contributor
 
Join Date: Jan 2010
Location: Charlotte, NC
Posts: 955
Default Re: JavaScript Table API – The Basics

Sure! Just remove the "=" between the SetContents function and its parameters:
Code:
myTable.Rows[0].SetContents("Earnings", 'Company Paid");
myTable.Rows[1].SetContents("Shift Differential Pay Overtime", Field("ShiftDifferenceOT"));
myTable.Rows[2].SetContents("Shift Differential Pay", Field("ShiftDifference"));
myTable.Rows[3].SetContents("Overtime Pay", Field("OTPay"));
myTable.Rows[4].SetContents("Regular Earnings", Field("RegEarnings"));
myTable.Rows[5].SetContents("Gross Earnings", Field("GrossEarnings"));
return myTable.MakeTags();
Btw, I think that apostrophe should be a quotation mark
__________________
Ste Pennell
FusionPro VDP Creator 9.3.15
Adobe Acrobat X 10.1.1
Mac OS X 10.12

LinkedIn
Reply With Quote
  #29  
Old January 3rd, 2013, 09:25 AM
Dan Korn's Avatar
Dan Korn Dan Korn is offline
FusionPro Senior Engineer / Forum Moderator
 
Join Date: Aug 2008
Location: Chicago, IL
Posts: 4,322
Default Re: JavaScript Table API – The Basics

Quote:
Originally Posted by -Lisa- View Post
Code:
myTable.Rows[0].SetContents = ("Earnings", 'Company Paid");
myTable.Rows[1].SetContents = ("Shift Differential Pay Overtime", Field("ShiftDifferenceOT"));
myTable.Rows[2].SetContents = ("Shift Differential Pay", Field("ShiftDifference"));
myTable.Rows[3].SetContents = ("Overtime Pay", Field("OTPay"));
myTable.Rows[4].SetContents = ("Regular Earnings", Field("RegEarnings"));
myTable.Rows[5].SetContents = ("Gross Earnings", Field("GrossEarnings"));
return myTable.MakeTags();
Any thoughts as to what I'm missing here?
FPTable.SetContents is a function, so you don't want the equal sign after it. The last few lines should look like this:
Code:
myTable.Rows[0].SetContents("Earnings", "Company Paid");
myTable.Rows[1].SetContents("Shift Differential Pay Overtime", Field("ShiftDifferenceOT"));
myTable.Rows[2].SetContents("Shift Differential Pay", Field("ShiftDifference"));
myTable.Rows[3].SetContents("Overtime Pay", Field("OTPay"));
myTable.Rows[4].SetContents("Regular Earnings", Field("RegEarnings"));
myTable.Rows[5].SetContents("Gross Earnings", Field("GrossEarnings"));
return myTable.MakeTags();
Actually, you can reduce a lot of the other logic in the rule with some "for" loops as well. So the entire rule could be this:
Code:
var myTable = new FPTable
myTable.AddColumns(17000, 8107);
myTable.AddRows(6);

for (var row = 0; row < 6; row++)
{
    for (var cell = 0; cell < 2; cell++)
    {
        myTable.Rows[row].Cells[cell].Font = "Times New Roman"; 
        myTable.Rows[row].Cells[cell].TextColor = "Black";
        myTable.Rows[row].Cells[cell].ShadeColor = "White"; 
        myTable.Rows[row].Cells[cell].ShadePct = 100;
    }
}

// first cell has inverted colors
myTable.Rows[0].Cells[0].TextColor = "White";
myTable.Rows[0].Cells[0].ShadeColor = "Black"; 

myTable.Rows[0].SetContents("Earnings", "Company Paid");
myTable.Rows[1].SetContents("Shift Differential Pay Overtime", Field("ShiftDifferenceOT"));
myTable.Rows[2].SetContents("Shift Differential Pay", Field("ShiftDifference"));
myTable.Rows[3].SetContents("Overtime Pay", Field("OTPay"));
myTable.Rows[4].SetContents("Regular Earnings", Field("RegEarnings"));
myTable.Rows[5].SetContents("Gross Earnings", Field("GrossEarnings"));
return myTable.MakeTags();
__________________
Dan Korn
FusionPro Developer / JavaScript Guru / Forum Moderator
PTI Marketing Technologies | Printable | MarcomCentral
LinkedIn

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
  #30  
Old January 3rd, 2013, 09:30 AM
-Lisa- -Lisa- is offline
Senior Contributor
 
Join Date: Sep 2008
Location: Long Island, NY
Posts: 189
Unhappy Re: JavaScript Table API – The Basics

Woops! I didn't catch that when I posted the code here.
I had it corrected when I copied the rule over into FP - but thanks for catching that!

I removed the "=" but now all I see when I preview this is the black fill in Column 1, Row, 1 - no content in either Column for Row 1.
I then see the content for Column 1, rows 2-6 but nothing in Column 2.

Ugh, I knew attacking this on my own was not a smart way to start the year!
Reply With Quote
Reply

Tags
javascript, tables

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 10:06 PM.


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