Expand my Community achievements bar.

SOLVED

Hide repeating table section

Avatar

Level 9

I am trying to hide only the repeating table sections ("ActionItemsGrp") that have a date entered in the "ClosedDate" date field when a button is clicked. This is the code I have been trying to get to work:

Capture1.PNG

This is my form hierarchy:

Capture2.PNG

Can't figure out what is wrong with the script.

1 Accepted Solution

Avatar

Correct answer by
Level 8

Oh ya no, subformSet's can't be hidden. Didn't see that.

Just take your existing code and add Row3 4 and 6 to hide...Also you don't need the third 'for' loop because your Row5 doesn't repeat.

Should look like this:

for (var a=0;a<Form1._Table1.count;a++){

for (var b=0;b<Form1.Table1.all.item(a)._ActionItemGrp.count;b++){

  if (Form1.Table1.all.item(a).ActionItemGrp.all.item(b).Row5.ClosedDate.rawValue!==null){

   Table1.all.item(a).ActionItemGrp.all.item(b).Row3.presence="hidden";

   Table1.all.item(a).ActionItemGrp.all.item(b).Row4.presence="hidden";

   Table1.all.item(a).ActionItemGrp.all.item(b).Row5.presence="hidden";

   Table1.all.item(a).ActionItemGrp.all.item(b).Row6.presence="hidden";

  }

}

}

Also it might be easier at this point to use plain subforms instead of tables. That way you could just wrap all those 'Rows' in a subform and hide that subform. The only time I use tables is when I want the cells in a row to expand equally during run-time.

Kyle

View solution in original post

15 Replies

Avatar

Level 8

What does it say in your JavaScript console (Ctrl-J)?

Kyle

Avatar

Level 9

When I click the button nothing happens.

Here's my console...

Capture3.PNG

Avatar

Level 8

Looks like the condition in your second 'for' loop doesn't include the instance index for your Table1: b<Form1.Table1.all.item(a)._ActionItemGrp.count

Kyle

Avatar

Level 9

This is what I have now but the button still does not work. Do you see anything else wrong? I only want to hide the entire "ActionItemGrp" when row 5 has a date in "ClosedDate" field.

Capture4.PNG

Avatar

Level 8

I see all.items when it should be all.item. That should definitely come up as an exception in your console.

Kyle

Avatar

Level 9

My console used to pop-up during errors but doesn't anymore. What settings are correct for Acrobat X under the javaScript settings window?

Capture5.PNG

Avatar

Level 9

Here's my form... can you take a look at it for me?

Click here for form in Workspaces

Avatar

Level 8

Can't always get Workspaces. Try this.

Kyle

Avatar

Level 9

Okay - I uploaded the file.

Thanks

Avatar

Level 9

This is what I see in the console:

Form1 is not defined

1:Console:Exec

ReferenceError: Form1 is not defined

1:Console:Exec

undefined

Avatar

Level 8

Opened your form, tried it out and the button works. Hides all the Row5's that have a Closed Date.

Kyle

Avatar

Level 9

Yes - but I am trying to get the button to hide the entire "ActionItemGrp" table sections - only those that have a ClosedDate in Row5. Those without a date remain open.

Avatar

Level 9

It appears table sections cannot be hidden. I need to find a script that will hide rows 3, 4, 5 and 6 (which make up the table section) only when row 5 has a closed date in the ClosedDate object.. The other sections/rows stay open.

Avatar

Correct answer by
Level 8

Oh ya no, subformSet's can't be hidden. Didn't see that.

Just take your existing code and add Row3 4 and 6 to hide...Also you don't need the third 'for' loop because your Row5 doesn't repeat.

Should look like this:

for (var a=0;a<Form1._Table1.count;a++){

for (var b=0;b<Form1.Table1.all.item(a)._ActionItemGrp.count;b++){

  if (Form1.Table1.all.item(a).ActionItemGrp.all.item(b).Row5.ClosedDate.rawValue!==null){

   Table1.all.item(a).ActionItemGrp.all.item(b).Row3.presence="hidden";

   Table1.all.item(a).ActionItemGrp.all.item(b).Row4.presence="hidden";

   Table1.all.item(a).ActionItemGrp.all.item(b).Row5.presence="hidden";

   Table1.all.item(a).ActionItemGrp.all.item(b).Row6.presence="hidden";

  }

}

}

Also it might be easier at this point to use plain subforms instead of tables. That way you could just wrap all those 'Rows' in a subform and hide that subform. The only time I use tables is when I want the cells in a row to expand equally during run-time.

Kyle