Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
BedrockMission!

Learn more

View all

Sign in to view all badges

Table of contents (Dynamic)

AgustinFC
Level 2
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
AgustinFC
Level 2
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.