Hide/Unhide Rows in Dynamic Table in LiveCycle

BernieBour

30-03-2018

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";
}

Accepted Solutions (1)

Accepted Solutions (1)

MinusZero

03-04-2018

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

Answers (6)

Answers (6)

BernieBour

04-04-2018

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");

}

}

MinusZero

02-04-2018

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.