Expand my Community achievements bar.

Dive into Adobe Summit 2024! Explore curated list of AEM sessions & labs, register, connect with experts, ask questions, engage, and share insights. Don't miss the excitement.
SOLVED

unhide/hide a field (table) using a button.

Avatar

Level 2

‌I have a table set to hidden and want to unhide it using a button and to hide it using the same button. If the table is left visible I don't want it to be able to be printe. Any suggestions?

thanks

1 Accepted Solution

Avatar

Correct answer by
Level 10

Alright, seems like it does not keep the flow of the form...

Another work around you can use that will work for sure would be the following:

1. Keep this code in the button click event

2. In your hierarchy, click on the table you want to hide when printing, go in the prePrint event and put this line (prePrint is before printing)

3. Now in the postPrint event you can put the following line to put back the table visible (postPrint is after printing)

Keep in mind that if the Table is hidden when printing, the table will appear in the postPrint.

So if you want to avoid this, you can have a hidden text field that keeps in memory how you should display the table after printing.

If you do this, you can change the value "visible" for TextField1.rawValue

You can put the text field's value using the button click event, when changing the presence value of the table change the text field's value as well

Hope this will help!

View solution in original post

6 Replies

Avatar

Level 10

Hi there,

in the button click's event you would have have something written like the following :

Make sure to put this in a JavaScript event

Hope this Help!

Avatar

Level 2

‌Works great except when I print it leaves a gap where the table was. I have the table default as hidden (exclude from layout).

thanks for your assistance so far.

Avatar

Level 10

Make sure your content's parents are all flowable

Avatar

Level 2

‌Every thing is flowed, all fields except the table are in flow able sub forms, and everything is enclosed in 1 flowable sub form.

am I able to send you a copy of the form?

Avatar

Correct answer by
Level 10

Alright, seems like it does not keep the flow of the form...

Another work around you can use that will work for sure would be the following:

1. Keep this code in the button click event

2. In your hierarchy, click on the table you want to hide when printing, go in the prePrint event and put this line (prePrint is before printing)

3. Now in the postPrint event you can put the following line to put back the table visible (postPrint is after printing)

Keep in mind that if the Table is hidden when printing, the table will appear in the postPrint.

So if you want to avoid this, you can have a hidden text field that keeps in memory how you should display the table after printing.

If you do this, you can change the value "visible" for TextField1.rawValue

You can put the text field's value using the button click event, when changing the presence value of the table change the text field's value as well

Hope this will help!

Avatar

Level 2

Brilliant, works perfectly, thanks very much for the help

Pete