Expand my Community achievements bar.

Guidelines for the Responsible Use of Generative AI in the Experience Cloud Community.
SOLVED

Hide/Unhide Rows in Dynamic Table in LiveCycle

Avatar

Level 2

I have an expanding table.  I have an Add Row button below the table and a Checkbox at the end of each row that will hide that row.  I need a button that will Show All Hidden Rows and another button to Hide All Hidden Rows.  This is working only on the first row of the table and not on any additional rows that have been added. Any help is greatly appreciated.

How do I attach a sample file on this forum?

This is the code I used to Hide Row Checkbox (on the Click event placed at the end of each row):

if (form1.Subform1.TableA.Row1.CheckBox1.rawValue == 1)

{

    form1.Subform1.TableA.Row1.presence = "hidden";

}
else

if (form1.Subform1.TableA.Row1.CheckBox1.rawValue == 0)  
{
form1.Subform1.TableA.Row1.presence = "visible";
}

Here is the code for the Show All Hidden Rows button (on the Click event):

this.resolveNode("TableA.Row1").presence = "visible";

Here is the code for the Hide All Hidden Rows button (on the Click event):

if (form1.Subform1.TableA.Row1.CheckBox1.rawValue == 1)

{

    form1.Subform1.TableA.Row1.presence = "hidden";

}
else

if (form1.Subform1.TableA.Row1.CheckBox1.rawValue == 0)
   
{
form1.Subform1.TableA.Row1.presence = "visible";
}

1 Accepted Solution

Avatar

Correct answer by
Level 7

No problem.

Using the instanceManager you can get a count for the instances if that helps to refine your code.

form1.Subform1.TableA.Row1.instanceManager.count

View solution in original post

7 Replies

Avatar

Level 7

It looks like the problem is that you are not referencing the repeated rows. All the rows you add to the table are effectively called Row1 and thats why it wont do it for the other rows added.

If you have a simple change like this:

//Row 1

if (form1.Subform1.TableA.Row1[0].CheckBox1.rawValue == 1)

{

    form1.Subform1.TableA.Row1[0].presence = "hidden";

}
else

if (form1.Subform1.TableA.Row1[0].CheckBox1.rawValue == 0)
   
{
form1.Subform1.TableA.Row1[0].presence = "visible";
}

//Row2

if (form1.Subform1.TableA.Row1[1].CheckBox1.rawValue == 1)

{

    form1.Subform1.TableA.Row1[1].presence = "hidden";

}
else

if (form1.Subform1.TableA.Row1[1].CheckBox1.rawValue == 0)
   
{
form1.Subform1.TableA.Row1[1].presence = "visible";
}

//Row3

if (form1.Subform1.TableA.Row1[2].CheckBox1.rawValue == 1)

{

    form1.Subform1.TableA.Row1[2].presence = "hidden";

}
else

if (form1.Subform1.TableA.Row1[2].CheckBox1.rawValue == 0)
   
{
form1.Subform1.TableA.Row1[2].presence = "visible";
}

This will then reference other repeated rows in the table.

Use the [0] additional code to create a reference to a row. Note that the first row is [0], the second row is [1], third [2] and so on.

Add as many if's as you need or perhaps create a while loop.

Avatar

Level 2

Thank you!  This is very helpful.  However, I don't know how many rows there will be.  There may be 20-50 rows.

Avatar

Correct answer by
Level 7

No problem.

Using the instanceManager you can get a count for the instances if that helps to refine your code.

form1.Subform1.TableA.Row1.instanceManager.count

Avatar

Level 2

Thanks again for your help.  It now works.

Code for Hide All button:

var vRows = TableA._Row1.count-1;

for (var i=vRows;i>=0;i--) {

if (TableA.resolveNode("Row1[" + i + "]").CheckBox1.rawValue!==0) {

(TableA.resolveNode("Row1[" + i + "]").presence="hidden");

}

}

Code for Show All button:

var vRows = TableA._Row1.count-1;

for (var i=vRows;i>=0;i--) {

if (TableA.resolveNode("Row1[" + i + "]").CheckBox1.rawValue!==0) {

(TableA.resolveNode("Row1[" + i + "]").presence="visible");

}

}

Avatar

Level 7

Congrats...i might copy your code for later reference

Avatar

Level 2

I found the code at True Tech Troubleshooting (a wonderful resource): 

Basic JavaScript Looping in Adobe LiveCycle Designer®