Expand my Community achievements bar.

Hide Column on Expanding Table

Avatar

Level 1

We have a form that has a table.  When the form opens, we have 1 out of the 5 columns, hidden on the table.  Let's say the Column 3 is the hidden column.  We have created that so far.

Beneath the table, we have a checkbox that that shows and hides Column 3.  This button works perfectly if we only have one row of data.  If there are multiple rows, this button applies to the first row only.

To get additional rows added to the table, we have an "Add Row" button and a "Remove Row" button, which adds or removes rows another beneath the first row.  When it adds the row, it adds 5 columns, regardless of what the checkbox previously mentioned says.  When that checkbox is checked, it should have 5 columns across.  When it's unchecked, there should be 4 columns across, with Column 3 hidden.  When the checkbox is unchecked, it is still creating 5 columns, because the 3rd column should be hidden.

I've searched and searched and haven't figured out how to get the checkbox to apply to all rows created in the table.  As previously mentioned, it works on the first row only.  How can I get the checkbox to apply to the dynamically created rows in addition to the first row?

The next question I have is, how can we create a row to the table with 4 columns when that checkbox is unchecked and 5 columns when that checkbox is checked?

The last question I will have will be in regards to getting a total added up in Column 5 of the table footer.  We will need to add up the fields in the table.

I was able to get all this to work properly with a static table with rows defined.  I haven't been able to figure this stuff out with a dynamic, expanding table.

I haven't seen where I can attach a pdf.  I know these are sometimes easier if the pdf is posted here also.  I don't think I'm allowed as this is my first post.

Thanks in advance.

1 Reply

Avatar

Level 1

Here is what the form looks like on opening...

783681_pastedImage_3.png

Here is what the form looks like when checking the Show/Hide Column checkbox...

783682_pastedImage_4.png

Here is what the form looks like with a row added...

783683_pastedImage_5.png

Here is what the form looks like with when we try to hide Column 3 with an added row...

783684_pastedImage_6.png

As you can see, only the header row, first row, and footer row are now hidden.  Rows 2+ do not get hidden.

How can we get Column 3 hidden for Rows 2+ with the checkbox?  I can't figure out what rows 2+ are called after they are added.  I tried using _, *, [*], (*) in different locations for the Show/Hide Column checkbox on Row1 for Column 3 and haven't figured it out.  I also tried putting the cells in Column 3 into a subform and still no luck.

The code for when the document loads (hides column 3), the Add Row button, the Remove Row button, and the Show/Hide Column checkbox is below.  Hopefully that can help people help me.

Any help is greatly appreciated.

Thanks.



form1::docReady - (JavaScript, client)


if (xfa.host.name != "XFAPresentationAgent") {

this.resolveNode("Subform1.Table1.HeaderRow.Cell3").presence = "hidden";

this.resolveNode("Subform1.Table1.Row1.Cell3").presence = "hidden";

this.resolveNode("Subform1.Table1.FooterRow.Cell3").presence = "hidden";

}

form1.#subform[0].Subform2.Button1::click - (JavaScript, client)

this.resolveNode('Subform1.Table1._Row1').addInstance(1);

if (xfa.host.version < 8) {

xfa.form.recalculate(1);

}

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

this.resolveNode('Subform1.Table1._Row1').removeInstance(0);

if (xfa.host.version < 8) {

xfa.form.recalculate(1);

}

form1.#subform[0].Subform3.CheckBox1::change - (JavaScript, client)

if (this.rawValue == "0") {

this.resolveNode("Subform1.Table1.HeaderRow.Cell3").presence = "hidden";

this.resolveNode("Subform1.Table1.Row1.Cell3").presence = "hidden";

this.resolveNode("Subform1.Table1.FooterRow.Cell3").presence = "hidden";

if (this.rawValue == "1") {

this.resolveNode("Subform1.Table1.HeaderRow.Cell3").presence = "visible";

this.resolveNode("Subform1.Table1.Row1.Cell3").presence = "visible";

this.resolveNode("Subform1.Table1.FooterRow.Cell3").presence = "visible";

}