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

dynamic tables (subforms)

Avatar

Level 4

I have a table that I want to have rows hidden that only become visible if the user checks a box. 

I'm running into some major problems:

1. Rows cannot be wrapped in subforms.

2. I wrapped each individual cell in a subform-there HAS to be a better way to do this.

3. I entered JS if/else statements in each cell subforum's calculate event. 

4. The overall table subform is set to flowed.

Now, this table has 4 rows. 2 of which should always be visible (row 1 and 3).  No problem there.  For some reason, I cannot get both row 2 and row 4 to appear.  If I preview PDF view, only the first checkbox I check will affect it's corresponding row.  So if I check checkbox 2, row 2 pops up between rows 1 and 3.  But checking checkbox 4 does nothing.  Vice versa if I check checkbox 4 first.  So i don't think it's a detail error in the coding.  I think wrapping cells in subforms wasn't the correct procedure.

*when I mentioned "row" in the above paragraph, I was talking about 2 cells that make up that row, wrapped in subforms that have identical JS coding.

I would post an example, but it should be easier for you to give me a kick in the right direction or show a previous similar example.

Thanks for any help!

1 Accepted Solution

Avatar

Correct answer by
Level 10

Hi,

You could abondon the Table object and just go with objects in a subform. If you look at the first link above, Table 6 is made with subforms and NOT the Table object.

If you stick with the Table, then it should not matter what objects are in each of the cells, as you are changing the presence property of the whole row.

Niall

View solution in original post

4 Replies

Avatar

Level 10

Hi,

First off I would not go down the route of inserting subforms into row cells, nor have script in the calculate event trying to change the presence property.

You can change the presence of the Row directly. For example the following in the click event of the checkbox should work (subject to changing the references to suit your form):

if (this.rawValue == true) {

     Table1.Row2.presence = "visible";

     Table1.Row4.presence = "visible";

{

else {

     Table1.Row2.presence = "hidden";

     Table1.Row4.presence = "hidden";

{

There are examples here: http://assure.ly/gk8Q7a and http://assure.ly/fItII5.

Hope that helps,

Niall

Avatar

Level 4

Niall,

I like the approach. However, the first column is just text, so I cannot set it to visible or hidden...

I just had the idea of having multiple tables with only 1 row each-what do you think of that approach? It would be easy to set to "flowed" since they can easily be wrapped in subforms.

Thanks!

Avatar

Correct answer by
Level 10

Hi,

You could abondon the Table object and just go with objects in a subform. If you look at the first link above, Table 6 is made with subforms and NOT the Table object.

If you stick with the Table, then it should not matter what objects are in each of the cells, as you are changing the presence property of the whole row.

Niall

Avatar

Level 4

In my click event, I was referencing the row incorrectly. It was specified as the second cell in the row (a drop down list) so I changed it to just be the row.

No need to abandon the table.

Thanks! As always, very helpful.