Jump to content

Varying number of Rows and Colums


randdevin

Recommended Posts

I've got a project that the customer is wanting a table like layout. I've never have used Fusion Pro Tables so this will be a learning curve.

 

The issue is the amount of cells varies depending on the amount of info.

 

In this example 10 cells Max. ( 2 Columns 5 rows ).

I don't see an issue if they are suppling 10 names.

 

The issue is they are wanting to go to a single Column if their is less then 6 names. If their is more then 5 Names and an odd number of names they want the last Name to merge into a single Column.

 

Providing 3 screen shots of different options.

 

Is this even Possible? If so any help getting this done would be extremely helpful. Thanks Devin

Tables.zip

Link to comment
Share on other sites

Glad to here that it's possible.. I did not want to deep dive into to much info from the start if was not going to work.

 

So the Table needs to fit with in a certain size window. When it goes to a single column the width can stay the same.. I was thinking just merge them would work just fine.

Link to comment
Share on other sites

This is a pretty abstract question. There are a couple of table examples in the Frodo tutorial. You can control the number of rows and columns with a rule. If you can show what you have tried so far, or at least the data, then I, or someone else, might be able to make more specific suggestions.
Link to comment
Share on other sites

Whats the Frodo tutorial?

 

Right now I've been able to write a simple table like this example below.

I still need to figure many things things like how do I even get other fields added to a cell?

 

But the bigger issue is how do I make this dynamic based on the fields used.

I've uploaded a sample data set that I made to for testing.

 

var myTable = new FPTable;
myTable.AddColumns(10800, 10800);
myTable.AddRows(3);
myTable.Rows[0].Cells[0].Content = Field("Name1");
myTable.Rows[0].Cells[1].Content = Field("Name2");
myTable.Rows[1].Cells[0].Content = Field("Name3");
myTable.Rows[1].Cells[1].Content = Field("Name4");
myTable.Rows[2].Cells[0].Content = Field("Name5");
myTable.Rows[2].Cells[1].Content = Field("Name6");
return myTable.MakeTags()

DataFile.zip

Link to comment
Share on other sites

So I figured out 2 ways I can place multiple fields in to my Cells.

 

First would be calling multiple Fileds as part as the Table Rule

 

myTable.Rows[0].Cells[0].Content = Field("Name1") + '<br>' + Field("Location1") + '<br>' + Field("Phone1");

 

Or I could call make another Rules for each cell

return [
   Field("Name1"),
   Field("Location1"),
   Field("Phone1")
].join('<p verticalstart=topofcolumn>');

 

Then the Table rule would be like this

myTable.Rows[0].Cells[1].Content = Rule("Cell1");

 

My question still stands on how to write the Table for the Varying number of Rows and Columns. Any Help in guiding me would be great. Thanks

Link to comment
Share on other sites

Whats the Frodo tutorial?

From the menu in Acrobat, select FusionPro -> Documentation -> Tutorials, then open the FrodoTravel tutorial. If you haven't looked at these, or read the User Guide, I encourage you to do both.

Right now I've been able to write a simple table like this example below.

I still need to figure many things things like how do I even get other fields added to a cell?

You seem to have figured that out. The content of each cell can be whatever you want, built up from whatever data fields you want.

But the bigger issue is how do I make this dynamic based on the fields used.

I've uploaded a sample data set that I made to for testing.

Thanks, that gives me something to work with. I came up with this rule:

var maxNames = 10;

var myTable = new FPTable;
var names = [];
for (var i = 1; i <= maxNames; i++)
   names.push(Field("Name" + i));

names = names.filter(Trim);

var numColumns = (names.length < 6) ? 1 : 2;

for (var c = 1; c <= numColumns; c++)
   myTable.AddColumn(16000);

var fieldNum = 0;
while (fieldNum < names.length)
{
   var row = myTable.AddRow();
   for (var c = 0; c < numColumns; c++)
   {
       fieldNum++;

       var fieldNames = ["Name", "Location", "Phone"];
       var fields = fieldNames.map(function(name) { return TaggedDataField(name + fieldNum); }).filter(Trim);
       //fields.unshift(fieldNum);

       var cell = row.Cells[c];
       cell.Content = fields.join("<br>");

       cell.HAlign = "Center";
       cell.VAlign = "Middle";
       cell.SetBorders("Thin", "Black", "Top", "Bottom", "Left", "Right");
       cell.Margins = { Top:100, Bottom:100 };

       if (fieldNum > names.length)
       {
           if (numColumns > 1 && fieldNum % 2 == 0)
               row.Cells[c-1].HStraddle = 2;

           break;
       }
   }
}

return myTable.MakeTags();

I think that does pretty much what you want.

Link to comment
Share on other sites

Dan,

 

Looking over what you came up with and If I understand it correctly

 

This code is deremiitng how many columns.

 

var numColumns = (names.length < 6) ? 1 : 2;

 

And this part is how wide to make them and how many based on numColumns

for (var c = 1; c <= numColumns; c++)
   myTable.AddColumn(16000);

 

If that is the case then I'm guess adding another if statement if less then 5 then make the column 32000. ( Double)?

Link to comment
Share on other sites

Think I got it working.

I added a simple If statement

 

var numColumns = (names.length < 6) ? 1 : 2;
for (var c = 1; c <= numColumns; c++)
if ( numColumns <= 1 ) 
   myTable.AddColumn(32000);
else
   myTable.AddColumn(16000);

 

Thanks Dan..

I will start modifying the format for the customers needs..

Link to comment
Share on other sites

Dan,

 

Is there away I can do a copy fit and not allow Line Breaks?

 

I've used your code for past projects but I've never had to worry about Line Breaking when using Java.

 

http://forums.pti.com/showthread.php?t=84&highlight=CopyFitLine

 

I've been digging thru the forum and Doc's and not seeing anything that is use full for my case.

 

Thanks

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