Expand my Community achievements bar.

Don’t miss the AEM Skill Exchange in SF on Nov 14—hear from industry leaders, learn best practices, and enhance your AEM strategy with practical tips.
SOLVED

referencing repeating rows in a repeating subform - argh - this can't be this difficult. thx.

Avatar

Level 1

Hi folks,

I'm sure this is a simple fix -- but I've been banging my head for a few days on it.

I have a Table (Table1) which contains

     a section (SectionArea) (repeating),

          each SectionArea has Row1, Datarow (repeating), Row3

Capture.PNG

I have the standard + - buttons on the sectionArea, they work fine.

Add

var nIndex = SectionArea.index;

_SectionArea.addInstance();

Delete

_SectionArea.removeInstance(SectionArea.index);

The Datarow add button works fine with:

var nIndex = Datarow.index;
var s = "SectionArea[" + SectionArea.index + "].Datarow"
xfa.resolveNode(s).instanceManager.addInstance(0);

It is the Delete button on the Datarow that I cannot figure out how to make work

app.alert(Datarow.index);
_Datarow.removeInstance(Datarow.index);

In the case of a form that ends up with:

SectionArea[0]

     Datarow[0]

     Datarow[1]

     Datarow[3]

SectionArea[1]

     Datarow[?]

     Datarow[?] *

when the delete event is called on the * row, what should the syntax be to remove that datarow?

     is it _Datarow.removeInstance[5]?

     is it _Datarow.removeInstance[2]?

     is it SectionArea[1].Datarow.removeinstance[2]?

     is it SectionArea[1].Datarow.removeinstance[5]?

how do I do this programatically?

I'm guessing it is simple. Part of my problem is not understanding how to reference the specific row, what this.parent.index is, is datarow index -- all datarows, or only the datarows inside this particular SectionArea?

My head is getting sore.thanks in advance --

cheers

Dean.

     ????

1 Accepted Solution

Avatar

Correct answer by
Level 10

Hi Dean,

It looks like the instance of the repeating Datarow continues/spans across multiple instances of the SectionArea.

Parallels Desktop.png

So have a look at this version on page2, where I have created a repeatable subform in a flowed layout (for the SectionArea) and a Table with a repeating row: https://acrobat.com/#d=-yiMpjWKM2nq6sMGIZctDQ.

Good luck,

Niall

View solution in original post

4 Replies

Avatar

Level 10

Hi Dean,

You are nearly there with the delete.

Because the delete button is within the Datarow, it only knows the instance of SectionArea that it is inside. Therefore when the script refers to Datarow, it uses the instances of Datarow within that SectionArea. So the first part of the script is okay:

_Datarow.removeInstance(...

Make sense so far?

The only problem is when you are scripting the particular instance of Datarow to delete. Here I would use the reference to the parent of the button, eg the particular instance of Datarwo that contains the button, irrespective of which section is it on. So, this should work:

_Datarwo.removeInstance(this.parent.index);

Here is an example for building dynamic tables http://assure.ly/gk8Q7a. Also here is an example for SMO Expressions http://assure.ly/kUP02y.

Hope that helps,

Niall

Avatar

Level 1

Niall,

thanks for the quick response -- my brain is a little less sore. I read the links you suggested. It makes sense what you are suggesting --- I'm missing something obvious because based on what I'm reading, I too think it should work - but what I think and reality are so often different.

The index appears to be the index of all Datarow's, as opposed to the index of the Datarow within this section. It doesn't appear that the row consistently deletes  (it does if the rows are in SectionArea[0])

The delete code is

form1.#subform[0].Table1.SectionArea.Datarow.Del::initialize - (JavaScript, client)
var nIndex = Datarow.index;
if (Datarow.index != 0) {
  this.presence = "visible";
} else {
  this.presence = "hidden";
}

form1.#subform[0].Table1.SectionArea.Datarow.Del::click - (JavaScript, client)
app.alert(Datarow.index);  <---- should these be the same index?
app.alert(this.parent.index) <-----------
_Datarow.removeInstance(this.parent.index);
if (this.parent.index ==0)
  this.presence = "hidden";

I posted a test form at https://acrobat.com/app.html#d=ILNhivI4MIM8BCxeWPaf-Q

Any help would be greatly appreciated.

Cheers

Dean.

Avatar

Correct answer by
Level 10

Hi Dean,

It looks like the instance of the repeating Datarow continues/spans across multiple instances of the SectionArea.

Parallels Desktop.png

So have a look at this version on page2, where I have created a repeatable subform in a flowed layout (for the SectionArea) and a Table with a repeating row: https://acrobat.com/#d=-yiMpjWKM2nq6sMGIZctDQ.

Good luck,

Niall

Avatar

Level 1

Niall, you rock.

I have spent more hours than I care to admit on this.

However, doing the same thing over and over again -- and getting the same result -- I'm sure there is a learning in there somethere for me.

thanks again.