Expand my Community achievements bar.

SOLVED

Problem with buttons in repeated table header

Avatar

Level 10

I have a bunch of tables that expand/contract at the click of a button in their respective header rows.

The problem I'm having is when a table breaks to another page the button doesn't work properly in the repeated header - the scripted value isn't making it to the repeated button (I've also tried checkboxes).

Is there any way to make this happen? Should I try using variables to store a flag or something like that?

https://acrobat.com/#d=m7zuQYiUoFrtz5isD7rErQ

1 Accepted Solution

Avatar

Correct answer by
Former Community Member

You can use the layout methods to tell you if your table spans two pages or one and if it does you can change the + to a - for all occurances of that button. The code woudl  look like this on the Initialize event.:

if

(xfa.layout.pageSpan(this.parent.parent) > 1){

     this.resolveNode("caption.value.#text").value

= "-";

}

This works great but if I click the - button on the second page then the 1st page button is out of sync and needs to be reset as well.

Paul

View solution in original post

4 Replies

Avatar

Level 4

This issue is that the second header is an instance of the first, so all unmanaged relative code breaks. I would hazzard a guess to say that your add code looks like "$.parent.row1.instanceManager.addInstance(1)." This will break, as the "second" header row no longer sees the 'table' element as it's parent.

Changing to code to a static reference will fix it... i.e. xfa.form.form1.table1.row1.instanceManager.addInstance(1).

This should solve it for you... if not, let me know.

- Scott

Avatar

Correct answer by
Former Community Member

You can use the layout methods to tell you if your table spans two pages or one and if it does you can change the + to a - for all occurances of that button. The code woudl  look like this on the Initialize event.:

if

(xfa.layout.pageSpan(this.parent.parent) > 1){

     this.resolveNode("caption.value.#text").value

= "-";

}

This works great but if I click the - button on the second page then the 1st page button is out of sync and needs to be reset as well.

Paul

Avatar

Level 10

Thanks guys! I knew it had something to do with instances but wasn't sure how to proceed.

Scott - it's a little more involved than that, I'm passing the table's somExpression to a script object which handles hiding and showing rows. Probably complicating the fact is that the tables are instances as well for a prePrint script I have that runs through the tables and hides rows if they aren't used.

Paul - that did the trick.  I made it an if/else and put it on the layout:ready event, the initialize event wasn't working for the if/else.

Avatar

Level 10

Well, it's almost working...I think I'm going to have to go with the set-a-flag technique to monitor whether a table is expanded or not.

The following has evaluated to null or missing: ==> liqladmin("SELECT id, value FROM metrics WHERE id = 'net_accepted_solutions' and user.id = '${acceptedAnswer.author.id}'").data.items [in template "analytics-container" at line 83, column 41] ---- Tip: It's the step after the last dot that caused this error, not those before it. ---- Tip: If the failing expression is known to be legally refer to something that's sometimes null or missing, either specify a default value like myOptionalVar!myDefault, or use <#if myOptionalVar??>when-present<#else>when-missing. (These only cover the last step of the expression; to cover the whole expression, use parenthesis: (myOptionalVar.foo)!myDefault, (myOptionalVar.foo)?? ---- ---- FTL stack trace ("~" means nesting-related): - Failed at: #assign answerAuthorNetSolutions = li... [in template "analytics-container" at line 83, column 5] ----