Expand my Community achievements bar.

Table of contents (Dynamic)

Avatar

Level 2


Hi all,

I am new with livecycle designer and I am trying to create a table of content.
We have different Sections, with variable length for each one, and we need to create a simple table of content (navigation no needed) something like:

Section 1  - Pag. 1
Section 2  - Pag. 4
...

Sections contains tables, so they could flow, which means the length of each section could be different. Obviously, the Table of Content page should be at the beggining, before the content.

At first, I tried to save in a table the Section Title and PageNumber for each Section.

Using the following javascript:

var oNewInstance = Page.TABLE._DATA.addInstance(0);

oNewInstance.Title.rawValue =  this.rawValue;

oNewInstance.page.rawValue = xfa.layout.page(this);

My problem is:
If the code is added to layout:ready event of Section page, it goes to an infinite loop (I guess, everytime I add a new instance to table, the event is called)

I tried with other events like form:ready, in this case, the Section title is working properly but the page number always shows -1.

Any idea? I'm pretty sure it should not be difficult, but I am not able to find the key.

Thanks a lot,

Kr,

Agustín.

1 Reply

Avatar

Level 2

Solved myself, using a condition in layout:ready event.

var total = Page.TABLE.DATA.all.length;

var max = Sections.all.length;

if(total <= max) {

var oNewInstance = Page.TABLE._DATA.addInstance(0);

oNewInstance.Title.rawValue =  this.rawValue;

oNewInstance.page.rawValue = xfa.layout.page(this);

xfa.form.recalculate(1);

}

Agustín.