PDA

View Full Version : Can text from 1 table overflow into another table?


gregmaze
September 19th, 2012, 09:04 AM
Greetings...

I was wondering if there is a way to have text from 1 table to overflow into another? I have created a table that spans 3 columns. When I add the variables to the tables the text only appears in the 1st LONG column.

I wanted the tables to share all the data and instead of 1 column with 12 items, I would have 3 columns with 4 items.

I am including an PDF image file to show what I am looking for.

Thank you
Greg Maze
MAC OS X 10.6.8 Fusion Pro 8.0.20

Dan Korn
September 19th, 2012, 12:08 PM
From the example, it looks to me that you don't really want a table at all; you actually want a text frame with three columns.

gregmaze
September 20th, 2012, 12:00 PM
Hello Dan,

Thanks for getting back with me. The reason I thought I needed a table was I did not think you could get a vertical rule to fit inside the table between the columns. The number of rows are variable.

So the question now is can I get a vertical rule to print in between the columns and resize it's height?

Thanks
Greg

Dan Korn
September 20th, 2012, 03:43 PM
The reason I thought I needed a table was I did not think you could get a vertical rule to fit inside the table between the columns. The number of rows are variable.

Okay, well, in that case, you do need a table. All you have to do is add some simple logic to rearrange the entries so that they go three-across into table rows, instead of just all in the first column. Something like this:
var table = new FPTable;
table.AddColumns(10000, 10000, 10000);
table.SetBorders("Thin", "Black", "Top", "Bottom");
for (var r = 1; r <= 4; r++)
{
var row = table.AddRow();
for (var c = 0; c < 3; c++)
{
row.Cells[c].SetBorders("Thin", "Black", "Left", "Right");
row.Cells[c].Content = "&bull; widget " + (r + (c * 4));
}
}
return table.MakeTags();

gregmaze
September 25th, 2012, 08:18 AM
Hello Dan,

Thank you for helping with this. I am still having a problem with this. I am including a jpg file to show what I am getting. What I am looking to get is a 3 column table that will take the amount of "widgets" and break them evenly across the 3 columns. The "widgets" are variable and the number of them will vary.

So if there were 12 "widgets" into 3 columns equal 4 "widgets" each column.
If there were 15 "widgets" into 3 columns equal 5 "widgets each column.

I would greatly appreciate any help.

Thank you
Greg

Dan Korn
September 25th, 2012, 09:40 AM
Okay, change the first line for a different number of widgets:
var numWidgets = 14;

var numRows = Int((numWidgets + 2) / 3);
var table = new FPTable;
table.AddColumns(10000, 10000, 10000);
table.SetBorders("Thin", "Black", "Top", "Bottom");
var widgetNum = 0;
for (var r = 1; r <= numRows; r++)
{
var row = table.AddRow();
for (var c = 0; c < 3; c++)
{
widgetNum = r + (c * numRows);
row.Cells[c].SetBorders("Thin", "Black", "Left", "Right");
if (widgetNum <= numWidgets)
row.Cells[c].Content = "&bull; widget " + widgetNum;
}
}
return table.MakeTags();

gregmaze
September 27th, 2012, 10:49 AM
Hello Dan,

Thanks for getting back to me on this.
I am still confused by this script. I understand how it works and how to add manually to the number of widgets. What I am having a problem with is how to get the number to be variable. As the customer will select from a list of items to put in the table. Ex. Widget1, Widget2, Widget3 etc. These are all in different fields. I am not sure how to count these selected fields. I am so close to completing this project and I am hung up on this.
If you could explain this a little better for someone who is not as advanced in Javascript, I would be so grateful...:)

Thank you

Dan Korn
September 27th, 2012, 12:00 PM
I am still confused by this script. I understand how it works and how to add manually to the number of widgets. What I am having a problem with is how to get the number to be variable. As the customer will select from a list of items to put in the table. Ex. Widget1, Widget2, Widget3 etc. These are all in different fields. I am not sure how to count these selected fields. I am so close to completing this project and I am hung up on this.
If you could explain this a little better for someone who is not as advanced in Javascript, I would be so grateful...:)
I'm trying to generalize since I don't know all the details of your job. So you have data fields named "Widget1", "Widget2", etc., and they're either populated or empty? If so, try this:
var numWidgets = 0;
try
{
while (Field("Widget" + (numWidgets + 1)))
numWidgets++;
}
catch (e)
{}

var numRows = Int((numWidgets + 2) / 3);
var table = new FPTable;
table.AddColumns(10000, 10000, 10000);
table.SetBorders("Thin", "Black", "Top", "Bottom");
var widgetNum = 0;
for (var r = 1; r <= numRows; r++)
{
var row = table.AddRow();
for (var c = 0; c < 3; c++)
{
widgetNum = r + (c * numRows);
row.Cells[c].SetBorders("Thin", "Black", "Left", "Right");
if (widgetNum <= numWidgets)
row.Cells[c].Content = "&bull; " + Field("Widget" + widgetNum);
}
}
return table.MakeTags();If that's doesn't work, then you'll need to post a more specific example of what your data file looks like, or better yet, the collected job, so that I can give a more specific answer.

gregmaze
September 27th, 2012, 01:38 PM
Well there is a reason why you have on a Superman Outfit...

But... of course there is a small error. I am including the collected file. It works fine if all fields are used, but if 1 field is not used every field after does nor show up.

Thank you Dan for all your help:)

gregmaze
September 27th, 2012, 01:44 PM
Here is the collected file.

Dan Korn
September 27th, 2012, 01:44 PM
But... of course there is a small error. I am including the collected file.
I don't see any attachment.
It works fine if all fields are used, but if 1 field is not used every field after does nor show up.
I was assuming that the fields would be filled in sequentially. If they're not, then I need to know the maximum number which the user can fill out, so that I know how many to check for in a loop.

Dan Korn
September 27th, 2012, 01:49 PM
Okay, there are up to 15 fields, "Excluded1" through "Excluded15", so this should work:
var numWidgets = 0;
for (var i = 1; i <= 15; i++)
{
if (Field("Excluded" + i))
numWidgets++;
}

var numRows = Int((numWidgets + 2) / 3);
var table = new FPTable;
table.AddColumns(24000, 24000, 24000);
table.SetBorders("Thin", "Black", "Top", "Bottom");
var widgetNum = 0;
for (var r = 1; r <= numRows; r++)
{
var row = table.AddRow();
for (var c = 0; c < 3; c++)
{
widgetNum = r + (c * numRows);
row.Cells[c].SetBorders("Thin", "Black", "Left", "Right");
if (widgetNum <= numWidgets)
row.Cells[c].Content = "&bull; " + Field("Excluded" + widgetNum);
}
}
return table.MakeTags();

gregmaze
October 1st, 2012, 01:19 PM
Hello Dan,

Yes there are 15 fields at most that will be used.

This last script leaves a bullet and blank if 1 or more of the 15 does not get chosen.

Thanks for your help.

Dan Korn
October 2nd, 2012, 08:54 AM
This last script leaves a bullet and blank if 1 or more of the 15 does not get chosen.
Okay, try this instead:
var widgets = [];
for (var i = 1; i <= 15; i++)
widgets.push(Field("Excluded" + i))

widgets = widgets.filter(Boolean);
var numWidgets = widgets.length;
widgets.unshift("");

var numRows = Int((numWidgets + 2) / 3);
var table = new FPTable;
table.AddColumns(24000, 24000, 24000);
table.SetBorders("Thin", "Black", "Top", "Bottom");
var widgetNum = 0;
for (var r = 1; r <= numRows; r++)
{
var row = table.AddRow();
for (var c = 0; c < 3; c++)
{
widgetNum = r + (c * numRows);
row.Cells[c].SetBorders("Thin", "Black", "Left", "Right");
if (widgetNum <= numWidgets)
row.Cells[c].Content = "&bull; " + widgets[widgetNum];
}
}
return table.MakeTags();

gregmaze
October 3rd, 2012, 10:00 AM
Thank you very much Dan...

That worked great... :)