Expand my Community achievements bar.

SOLVED

Reset button and added rows

Avatar

Level 4

Hello,

I've recently being making a dynamic flowable table with an "add a row" button.  I've also added a reset button to the form and it clears out all the text well, but I was wondering if there was any way for it to reset the rows in the table to 1.  I saw another post that indicated a reset button couldn't do that, but I wasn't not completely clear about that in the post.  Input would be appreciated.  Thanks!

1 Accepted Solution

Avatar

Correct answer by
Former Community Member

Looks like you are operating on the wrong table. Try...

// form1.#subform[0].Subform1.Button2::click - (JavaScript, client)

xfa.host.resetData();


var cnt = Subform2.Table.Table1._Row1.count;


for (var i=cnt; i > 1; i--) {

Subform2.Table.Table1._Row1.removeInstance(i-1);

}

rather than...

// form1.#subform[0].Subform1.Button2::click - (JavaScript, client)

xfa.host.resetData();


var cnt = Subform1._detail.count;


for (var i=cnt; i > 1; i--) {

  Subform1._detail.removeInstance(i-1);

}

Steve

View solution in original post

5 Replies

Avatar

Former Community Member

The attached contains a dynamic sub-form in which you can add and delete rows. I added a button called 'resetBtn' and add the following script on the click event. It gets the count of row instances, iterates over the sub-form removing row 2..n and then does a resetData() to clear row 1.


// form1.page1.detailHeader.resetBtn::click - (JavaScript, client)


var cnt = form1.page1._detail.count;


for (var i=cnt; i > 1; i--) {

  form1.page1._detail.removeInstance(i-1);

}


xfa.host.resetData();

Steve

Avatar

Level 4

I tried using the script you suggested in the post and the file and it did nothing.  Any other suggestions?  Thanks!

Avatar

Level 4

I'm still hoping to find a way to reset the number of rows in the table on my form when I hit the reset button.  I tried the scripting suggested, but it just isn't working.  I'm including a link to the form if some could give me a clue of what I need to do, I'd appreciate it.  https://acrobat.com/#d=yQV38javGYBkrNdlvcQbKw

Thanks!

Avatar

Correct answer by
Former Community Member

Looks like you are operating on the wrong table. Try...

// form1.#subform[0].Subform1.Button2::click - (JavaScript, client)

xfa.host.resetData();


var cnt = Subform2.Table.Table1._Row1.count;


for (var i=cnt; i > 1; i--) {

Subform2.Table.Table1._Row1.removeInstance(i-1);

}

rather than...

// form1.#subform[0].Subform1.Button2::click - (JavaScript, client)

xfa.host.resetData();


var cnt = Subform1._detail.count;


for (var i=cnt; i > 1; i--) {

  Subform1._detail.removeInstance(i-1);

}

Steve

Avatar

Level 4

Thank you so much.  I knew what I had originally been given wasn't correct and I was playing around with the script but I knew I wasn't right.

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] ----