MarcomCentral (PTI) and FusionPro User Communities

MarcomCentral (PTI) and FusionPro User Communities (http://forums.pti.com/index.php)
-   Tables & Charts (http://forums.pti.com/forumdisplay.php?f=36)
-   -   Varying number of Rows and Colums (http://forums.pti.com/showthread.php?t=5224)

randdevin September 27th, 2018 06:58 AM

Varying number of Rows and Colums
 
1 Attachment(s)
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

Dan Korn September 27th, 2018 09:49 AM

Re: Varying number of Rows and Colums
 
So is it just that a table gets resized to be narrower when there are fewer than six names, or does the whole output page get resized as well? Either is possible, but there are different approaches for those two requirements.

randdevin September 27th, 2018 10:25 AM

Re: Varying number of Rows and Colums
 
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.

randdevin October 1st, 2018 09:30 AM

Re: Varying number of Rows and Colums
 
Dan,

Just checking in and see if you have any ideas. I'm still trying to read over how to make tables and come close to what were needing.

Thanks

Dan Korn October 1st, 2018 01:24 PM

Re: Varying number of Rows and Colums
 
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.

randdevin October 2nd, 2018 08:24 AM

Re: Varying number of Rows and Colums
 
1 Attachment(s)
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.

Code:

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


randdevin October 2nd, 2018 04:00 PM

Re: Varying number of Rows and Colums
 
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

Code:

myTable.Rows[0].Cells[0].Content = Field("Name1") + '<br>' + Field("Location1") + '<br>' + Field("Phone1");
Or I could call make another Rules for each cell
Code:

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

Then the Table rule would be like this
Code:

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

Dan Korn October 3rd, 2018 10:11 AM

Re: Varying number of Rows and Colums
 
Quote:

Originally Posted by randdevin (Post 21480)
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.
Quote:

Originally Posted by randdevin (Post 21480)
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.
Quote:

Originally Posted by randdevin (Post 21480)
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:
Code:

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.

randdevin October 3rd, 2018 10:48 AM

Re: Varying number of Rows and Colums
 
Dan,

Thanks so much! This is just about their in what they are wanting.

The only issue that I'm seeing right now it's not centering the table in the text box when it's a single column.

randdevin October 3rd, 2018 11:21 AM

Re: Varying number of Rows and Colums
 
Dan,

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

This code is deremiitng how many columns.

Code:

var numColumns = (names.length < 6) ? 1 : 2;
And this part is how wide to make them and how many based on numColumns
Code:

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


All times are GMT -7. The time now is 09:32 AM.

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