Jump to content

Can text from 1 table overflow into another table?


gregmaze

Recommended Posts

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

columns.pdf

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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 = "• widget " + (r + (c * 4));
   }
}
return table.MakeTags();

Link to comment
Share on other sites

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

3-column-table.thumb.jpg.35f79ee9ce497a7168a2cb11c0970a42.jpg

Link to comment
Share on other sites

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 = "• widget " + widgetNum;
   }
}
return table.MakeTags();

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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 = "• " + 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.

Link to comment
Share on other sites

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:)

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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 = "• " + Field("Excluded" + widgetNum);
   }
}
return table.MakeTags();

Link to comment
Share on other sites

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 = "• " + widgets[widgetNum];
   }
}
return table.MakeTags();

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