Quantcast
Channel: Adobe Community : All Content - LiveCycle Designer
Viewing all articles
Browse latest Browse all 5571

Auto-resizing a dynamic table

$
0
0

Hello,

 

I have been working on a form in Licecycle Designer ES2 that requires the user to be able to insert a table. I have managed to work out a code that will do that by having a button with the following script in the click  event where I have a single-cell table and "Cell1" is a repeatable subform that acts as a cloumn:

 

// default rows and columns

var nRowCount = 3;

var nColCount = 4;

 

// ask user for row and column count

var sNumRows = xfa.host.response("How many rows?       (max 15)", "New Table", nRowCount.toString());

var sNumCols = xfa.host.response("How many columns?       (max X)", "New Table", nColCount.toString());

 

// get the user's response handling any invalid input

if (sNumRows != null && sNumRows.length > 0 && !isNaN(sNumRows))

    nRowCount = Number(sNumRows);

 

if (sNumCols != null && sNumCols.length > 0 && !isNaN(sNumCols))

    nColCount = Number(sNumCols);

   

   

xfa.resolveNode("Table2.Row1").instanceManager.count = sNumRows;

xfa.resolveNode("Table2.Row1.Cell1").instanceManager.count = sNumCols;

xfa.resolveNode("Table2.Row1[1].Cell1").instanceManager.count = sNumCols;

xfa.resolveNode("Table2.Row1[2].Cell1").instanceManager.count = sNumCols;

xfa.resolveNode("Table2.Row1[3].Cell1").instanceManager.count = sNumCols;

xfa.resolveNode("Table2.Row1[4].Cell1").instanceManager.count = sNumCols;

xfa.resolveNode("Table2.Row1[5].Cell1").instanceManager.count = sNumCols;

xfa.resolveNode("Table2.Row1[6].Cell1").instanceManager.count = sNumCols;

xfa.resolveNode("Table2.Row1[7].Cell1").instanceManager.count = sNumCols;

xfa.resolveNode("Table2.Row1[8].Cell1").instanceManager.count = sNumCols;

xfa.resolveNode("Table2.Row1[9].Cell1").instanceManager.count = sNumCols;

xfa.resolveNode("Table2.Row1[10].Cell1").instanceManager.count = sNumCols;

xfa.resolveNode("Table2.Row1[11].Cell1").instanceManager.count = sNumCols;

xfa.resolveNode("Table2.Row1[12].Cell1").instanceManager.count = sNumCols;

xfa.resolveNode("Table2.Row1[13].Cell1").instanceManager.count = sNumCols;

xfa.resolveNode("Table2.Row1[14].Cell1").instanceManager.count = sNumCols;

xfa.resolveNode("Table2.Row1[15].Cell1").instanceManager.count = sNumCols;

 

My question is a two parter. First, is there a better way to specify the duplication of columns in all rows? If I don't anticipate the rows as "Table2.Row1[x].Cell1" then only the first row will gain columns. Second, is there a way to automatically resize the width of the columns when the button is clicked? For instance, if the user chooses to have two rows, then I would like to have each column be about 3" wide. But if the user wants 3 columns, then they should each be about 2", and 4 columns would be about 1.5" each.

 

I have tried adding the following code (and as many variations as I can think of affecting the text field, the cell subform, the table, etc.) to the button's click action but it doesn't work:

 

if (sNumCols = "2") {

  this.resolveNode("Table2.Row1.Cell1").w = "3in";

  this.resolveNode("Table2.Row1.Cell1[1]").w = "3in";

}


Viewing all articles
Browse latest Browse all 5571

Trending Articles