scotts Posted January 23, 2023 Share Posted January 23, 2023 I'm new to tables and the forum is a great help. Thank you to everyone that posts. I have a project that I'm stuck on. A letter showing giving amounts in a small space using external data (which is also a first for me). But some of the data is too much to fit in the space so I need the table to start over with the header in a new text frame or add on to the table columns. Not sure how to do either. I have attached a sample document with sample data of what I'm working with and what I'm trying to do. I have left all the comments of the table rule in there until I have figured it all out, and so I can use this job as a sample for later. I have attache a zip of the PDF and CSV files. Along with a screenshot of the what it should kind of look like in the end. Granted it is using the same data in all 3 text frames, but that is only because I don't know how to get it to do it, yet. I'm on a Mac 10.13.6 using FP Creator v10.0.3.Archive.zipTable_Sample_Screenshot.pdf Quote Link to comment Share on other sites More sharing options...
scotts Posted January 23, 2023 Author Share Posted January 23, 2023 Sorry I did not post the code. Here it is, now that I've made some progress. I know I can only have my header and than 8 rows after that. So I'm trying to manually put in my breaks so I can get the headers when the table flows to another text frame. But I have found that when I do it the way I have it, I am losing one record of data. if(FusionPro.Composition.isPreview == true || FusionPro.inValidation == true) { Rule("OnJobStart"); } //Get a count of the total number of records in the external data file numRecsExtDF = externalDF.recordCount; /*============================================================================= || Create arrays to hold values that match the CID of the client's record ||=============================================================================*/ var clientMatch = []; var dateMatch = []; var amtMatch = []; // Step through the external data file and push matches into their respective variables if there is a match for (var i=1; i <= numRecsExtDF; i++) { if (externalDF.GetFieldValue(i, 'Constituent ID') == Field("Constituent ID")) { clientMatch.push(externalDF.GetFieldValue(i, 'Constituent ID')); dateMatch.push(externalDF.GetFieldValue(i, 'Gift Date')); amtMatch.push(externalDF.GetFieldValue(i, 'Gift Amount')); } } /*============================================================================= || Create the table ||=============================================================================*/ new FPTable; var myTable = new FPTable; myTable.AddColumns(5900, 7300, 3600); // 1 inch = 7200 pts // myTable.AddRows(clientMatch.length+2); // add 2 additional rows (Header and summary lines) myTable.AddRows(clientMatch.length+1); // add 1 additional rows (Header) if (clientMatch.length+1 <= 8) { // Table for records with less than 8 gifts. // HEADER ROW FORMATTING myTable.Rows[0].Cells[0].Font = "Book Antiqua"; myTable.Rows[0].Cells[0].PointSize = "11"; myTable.Rows[0].Cells[0].TextColor = "Black"; myTable.Rows[0].Cells[0].Margins = new FPTableMargins; myTable.Rows[0].Cells[0].Margins.Top = 20; myTable.Rows[0].Cells[0].Margins.Bottom = 20; myTable.Rows[0].Cells[0].HAlign = "Center"; myTable.Rows[0].Cells[0].VAlign = "Center"; myTable.Rows[0].CopyCells(0, 1, 2); // Apply the same formating to each cell in this row // HEADER ROW CONTENT myTable.Rows[0].SetContents("Date", "Amount", "i"); // interate through the length of the arrays (data matches from external data file) and create rows for (var i=1; i<=clientMatch.length; i++) { // TABLE CONTENT FORMATTING for date and amount values myTable.Rows[i].Cells[0].Font = "Book Antiqua"; myTable.Rows[i].Cells[0].PointSize = "9"; myTable.Rows[i].Cells[0].HAlign = "Center"; // myTable.Rows[i].Cells[0].VAlign = "Middle"; myTable.Rows[i].Cells[0].Margins = new FPTableMargins; myTable.Rows[i].Cells[0].Margins.Top = 20; myTable.Rows[i].Cells[0].Margins.Bottom = 20; myTable.Rows[i].CopyCells(0,1,2); // Apply the same formating to each cell in this row // CREATE CONTENT FOR EXTERNAL DATA FILE RECORDS myTable.Rows[i].SetContents(dateMatch[i-1], amtMatch[i-1], [i]); } } else if ((clientMatch.length+1 >= 9) && (clientMatch.length+1 <= 16)) { // Table for records with more than 8 gifts but less than 16. // HEADER ROW FORMATTING myTable.Rows[0].Cells[0].Font = "Book Antiqua"; myTable.Rows[0].Cells[0].PointSize = "11"; myTable.Rows[0].Cells[0].TextColor = "Black"; myTable.Rows[0].Cells[0].Margins = new FPTableMargins; myTable.Rows[0].Cells[0].Margins.Top = 20; myTable.Rows[0].Cells[0].Margins.Bottom = 20; myTable.Rows[0].Cells[0].HAlign = "Center"; myTable.Rows[0].Cells[0].VAlign = "Center"; myTable.Rows[0].CopyCells(0, 1, 2); // Apply the same formating to each cell in this row // HEADER ROW CONTENT myTable.Rows[0].SetContents("Date", "Amount", "i"); // interate through the length of the arrays (data matches from external data file) and create rows for (var i=1; i<=clientMatch.length; i++) { // TABLE CONTENT FORMATTING for header myTable.Rows[9].Cells[0].Font = "Book Antiqua"; myTable.Rows[9].Cells[0].PointSize = "11"; myTable.Rows[9].Cells[0].TextColor = "Black"; myTable.Rows[9].Cells[0].Margins = new FPTableMargins; myTable.Rows[9].Cells[0].Margins.Top = 20; myTable.Rows[9].Cells[0].Margins.Bottom = 20; myTable.Rows[9].Cells[0].HAlign = "Center"; myTable.Rows[9].Cells[0].VAlign = "Center"; myTable.Rows[9].CopyCells(0, 1, 2); // Apply the same formating to each cell in this row myTable.Rows[9].SetContents("Date", "Amount", "i"); // TABLE CONTENT FORMATTING for date and amount values myTable.Rows[i].Cells[0].Font = "Book Antiqua"; myTable.Rows[i].Cells[0].PointSize = "9"; myTable.Rows[i].Cells[0].HAlign = "Center"; // myTable.Rows[i].Cells[0].VAlign = "Middle"; myTable.Rows[i].Cells[0].Margins = new FPTableMargins; myTable.Rows[i].Cells[0].Margins.Top = 20; myTable.Rows[i].Cells[0].Margins.Bottom = 20; myTable.Rows[i].CopyCells(0,1,2); // Apply the same formating to each cell in this row // CREATE CONTENT FOR EXTERNAL DATA FILE RECORDS myTable.Rows[i].SetContents(dateMatch[i-1], amtMatch[i-1], [i]); } } else if (clientMatch.length+1 >= 17) { // Table for records with more than 16 gifts. // HEADER ROW FORMATTING myTable.Rows[0].Cells[0].Font = "Book Antiqua"; myTable.Rows[0].Cells[0].PointSize = "11"; myTable.Rows[0].Cells[0].TextColor = "Black"; myTable.Rows[0].Cells[0].Margins = new FPTableMargins; myTable.Rows[0].Cells[0].Margins.Top = 20; myTable.Rows[0].Cells[0].Margins.Bottom = 20; myTable.Rows[0].Cells[0].HAlign = "Center"; myTable.Rows[0].Cells[0].VAlign = "Center"; myTable.Rows[0].CopyCells(0, 1, 2); // Apply the same formating to each cell in this row // HEADER ROW CONTENT myTable.Rows[0].SetContents("Date", "Amount", "i"); myTable.Rows[9].SetContents("Date", "Amount", "i"); myTable.Rows[18].SetContents("Date", "Amount", "i"); // interate through the length of the arrays (data matches from external data file) and create rows for (var i=1; i<=clientMatch.length; i++) { // TABLE CONTENT FORMATTING for header // myTable.Rows[9].Cells[0].Font = "Book Antiqua"; // myTable.Rows[9].Cells[0].PointSize = "11"; // myTable.Rows[9].Cells[0].TextColor = "Black"; // myTable.Rows[9].CopyCells(0, 1); // Apply the same formating to each cell in this row // myTable.Rows[18].Cells[0].Font = "Book Antiqua"; // myTable.Rows[18].Cells[0].PointSize = "11"; // myTable.Rows[18].Cells[0].TextColor = "Black"; // myTable.Rows[18].CopyCells(0, 1); // Apply the same formating to each cell in this row // TABLE CONTENT FORMATTING for date and amount values myTable.Rows[i].Cells[0].Font = "Book Antiqua"; myTable.Rows[i].Cells[0].PointSize = "9"; myTable.Rows[i].Cells[0].HAlign = "Center"; // myTable.Rows[i].Cells[0].VAlign = "Middle"; myTable.Rows[i].Cells[0].Margins = new FPTableMargins; myTable.Rows[i].Cells[0].Margins.Top = 20; myTable.Rows[i].Cells[0].Margins.Bottom = 20; myTable.Rows[i].CopyCells(0,1,2); // Apply the same formating to each cell in this row // CREATE CONTENT FOR EXTERNAL DATA FILE RECORDS myTable.Rows[i].SetContents(dateMatch[i-1], amtMatch[i-1], [i]); } } return myTable.MakeTags(); Quote Link to comment Share on other sites More sharing options...
jwhittaker Posted January 24, 2023 Share Posted January 24, 2023 Scott, Here is a collect with a couple different options for you. I added an Overflow page and you can set your table frame to overflow into the overflow page text frame. I don't know of a way to have one overflow page with 3 different frames you can overflow into. I know others might know. I created a page 3 with you table rules and then others with a Header specified. I put a some text telling you which is which so you could see the difference. I hope this helps. If anyone knows how to use an Overflow page with multiple text frames that need to stay in separate text flows, please post. I would like to know how to do that also. Like this case, 3 different tables in 3 different text frames overflowing into 3 different text frames on the overflow page. JonNew folder.zip Quote Link to comment Share on other sites More sharing options...
scotts Posted January 25, 2023 Author Share Posted January 25, 2023 Thank jwhittaker for taking at crack at it. I cannot have the table go to another page, so that will not work for me. But I did create a solution. And here it is. I created the headers as separate text frames and suppressed them by default and used an 'OnRecordStart' rule to unsuppress them if needed. if(FusionPro.Composition.isPreview == true || FusionPro.inValidation == true) { Rule("OnJobStart"); } //Get a count of the total number of records in the external data file numRecsExtDF = externalDF.recordCount; /*============================================================================= || Create arrays to hold values that match the CID of the client's record ||=============================================================================*/ var clientMatch = []; // Step through the external data file and push matches into their respective variables if there is a match for (var i=1; i <= numRecsExtDF; i++) { if (externalDF.GetFieldValue(i, 'Constituent ID') == Field("Constituent ID")) { clientMatch.push(externalDF.GetFieldValue(i, 'Constituent ID')); } } /*============================================================================= || Determine if Header Text Frames need to be hidden ||=============================================================================*/ var Header1 = FindTextFrame("Header_1"); var Header2 = FindTextFrame("Header_2"); var Header3 = FindTextFrame("Header_3"); Header2.suppress = true; Header3.suppress = true; if (clientMatch.length >16) { Header2.suppress = false; Header3.suppress = false; } if ((clientMatch.length <=16) && (clientMatch.length >=9)) { Header2.suppress = false; Header3.suppress = true; } And then my table would span through the three text frames just fine with the "headers" being "turned" on if needed. Here's the 'Header Table Rule'. /*============================================================================= || Create the table ||=============================================================================*/ new FPTable; var myTable = new FPTable; myTable.AddColumns(5900, 7300); // 1 inch = 7200 pts myTable.AddRows(1); // HEADER ROW FORMATTING myTable.Rows[0].Cells[0].Font = "Arial"; myTable.Rows[0].Cells[0].PointSize = "11"; myTable.Rows[0].Cells[0].TextColor = "Black"; myTable.Rows[0].Cells[0].Margins = new FPTableMargins; myTable.Rows[0].Cells[0].Margins.Top = 20; myTable.Rows[0].Cells[0].Margins.Bottom = 20; myTable.Rows[0].Cells[0].HAlign = "Center"; myTable.Rows[0].Cells[0].VAlign = "Center"; myTable.Rows[0].CopyCells(0, 1); // Apply the same formating to each cell in this row // HEADER ROW CONTENT myTable.Rows[0].SetContents("Date", "Amount"); return myTable.MakeTags();And here's my actual table rule for the external data. I left the header row in there, because I couldn't figure out how to remove it and still get the rule to validate it. And just adjusted my next two text frames without the header to line up with my first data row. Simple enough. if(FusionPro.Composition.isPreview == true || FusionPro.inValidation == true) { Rule("OnJobStart"); } //Get a count of the total number of records in the external data file numRecsExtDF = externalDF.recordCount; /*============================================================================= || Create arrays to hold values that match the CID of the client's record ||=============================================================================*/ var clientMatch = []; var dateMatch = []; var amtMatch = []; // Step through the external data file and push matches into their respective variables if there is a match for (var i=1; i <= numRecsExtDF; i++) { if (externalDF.GetFieldValue(i, 'Constituent ID') == Field("Constituent ID")) { clientMatch.push(externalDF.GetFieldValue(i, 'Constituent ID')); dateMatch.push(externalDF.GetFieldValue(i, 'Gift Date')); amtMatch.push(externalDF.GetFieldValue(i, 'Gift Amount')); } } /*============================================================================= || Create the table ||=============================================================================*/ new FPTable; var myTable = new FPTable; myTable.AddColumns(5900, 7300); // 1 inch = 7200 pts // myTable.AddRows(clientMatch.length+2); // add 2 additional rows (Header and summary lines) myTable.AddRows(clientMatch.length+1); // acutal rows needed // HEADER ROW FORMATTING myTable.Rows[0].Cells[0].Font = "Arial"; myTable.Rows[0].Cells[0].PointSize = "11"; myTable.Rows[0].Cells[0].TextColor = "Black"; myTable.Rows[0].Cells[0].Margins = new FPTableMargins; myTable.Rows[0].Cells[0].Margins.Top = 20; myTable.Rows[0].Cells[0].Margins.Bottom = 20; myTable.Rows[0].Cells[0].HAlign = "Center"; myTable.Rows[0].Cells[0].VAlign = "Center"; myTable.Rows[0].CopyCells(0, 1); // Apply the same formating to each cell in this row // HEADER ROW CONTENT myTable.Rows[0].SetContents(" ", " "); // interate through the length of the arrays (data matches from external data file) and create rows for (var i=1; i<=clientMatch.length; i++) { // TABLE CONTENT FORMATTING for date and amount values myTable.Rows[i].Cells[0].Font = "Arial"; myTable.Rows[i].Cells[0].PointSize = "9"; myTable.Rows[i].Cells[0].HAlign = "Center"; myTable.Rows[i].Cells[0].VAlign = "Middle"; myTable.Rows[i].Cells[0].Margins = new FPTableMargins; myTable.Rows[i].Cells[0].Margins.Top = 20; myTable.Rows[i].Cells[0].Margins.Bottom = 20; myTable.Rows[i].CopyCells(0,1); // Apply the same formating to each cell in this row // CREATE CONTENT FOR EXTERNAL DATA FILE RECORDS myTable.Rows[i].SetContents(dateMatch[i-1], amtMatch[i-1]); } return myTable.MakeTags(); And again, I've included my updated sample files for anyone to see. (PDF, data and external data)Archive.zip Quote Link to comment Share on other sites More sharing options...
jwhittaker Posted January 30, 2023 Share Posted January 30, 2023 Scotts, I see now, I had just noticed your original frames were named Table1, Table2 and Table3. I duplicated your page and created a new rule called Table_header. This template is based on the rule I had sent back called Table_with_header. I modified it for your instance. Line 38 is where you set the Header row. This is where the table flows into another frame it will add a new header row automatically. This will eliminate the need for the extra header frames and rules. myTable.Rows[0].Type = "Header"; I also added some code to "skip" a line at the top of the Table_header rule that is commented out. You can use it on some conditional logic. myTable.Rows[0].Type = "Skip"; Hope that helps. JonTable_Samplex2.zip 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.