Expand my Community achievements bar.

Choosing between different table versions (rows) within a document doesn't work?

Avatar

Former Community Member

I created a new page which will display 1 of 2 versions of a table.  Only 1 version will display.  Never both.  The tables differ in that one has one more column than the other.  I need to maintain the width of the table to be the same.  New to Designer, I have learned that writing script to make visible is flawed for my needs.  It's flawed because within each table there is a repeating row that is bound to the same field.  Table1.Row1 binds to InvoiceDetailData fields.  Table2.Row1 binds to the same InvoiceDetailData fields.  Those with experience will probably know that when rendered, Table2 will not have any data in the Row1 because the data was already used in Table1.Row1.  Is there a function in Designer ES2, rather than make visible or hide, to "choose" between my table versions before setting the binding?

Thanks in advance.

1 Reply

Avatar

Level 10

Hi,

The closest you will come to a function in Designer is a subformset with a "Select One Subform from Alternatives", then you can show a subform depending on an elements name in your data connection.  So if you data connection looks like;

<Page1>
   <Red>
      <Row1>
         <TextField1/>
         <TextField2/>
         <TextField3/>
         <TextField4/>
      </Row1>
   </Red>
</Page1>

and you have one of the subforms in the set bound to Red and another bound to Green then changing the name of the element and call the remerge() method will show the other subform;

That is;

Page1.dataNode.nodes.item(0).name = "Green";
xfa.form.remerge();

Calling remerge can cause some problems as any changes to the properties of your form objects that are not bound will be reset to their initial values.  Things like changing the border color, etc.

This might be best if the user can change values in the fields of both tables.

An alternative is to have some code in the Calculate event of a subform containing the two tables that keeps them in sync.  This works well when one is a summary of the other, or a read-only version, otherwise you will need to put code in the exit event of each field in the second table to update the value in the field table.

Anyway here is a sample showing both approaches https://sites.google.com/site/livecycledesignercookbooks/home/subformset.pdf?attredirects=0&d=1.

I hope it helps

Bruce