Expand my Community achievements bar.

Hide Specific Table Rows and Subforms based on CheckBox Value

Avatar

Level 2

Attempting to make a document as follows:

OK, I almost have this working - what is wrong with my code?

******************

form1.page1.printingSF.PrintButton2::click - (JavaScript, client)

var startTime = new Date(); // to measure performance

page1.presence = "hidden";

page1hidden.presence = "visible";

var j = 0;

for (var i=0; i<=15; i++)

{

    var oRow = xfa.resolveNode("Table1.Row1[" + i + "]");

    if(oRow.checkcol.rawValue != "0")

    {

        page1hidden.Table1._Row1.addInstance(true);

        var oHidden = xfa.resolveNode("page1hidden.Table1.Row1[" + j + "]");

        j += 1;

        oHidden.checkcol.rawValue = oRow.checkcol.rawValue;

        oHidden.txtitem.rawValue = oRow.txtitem.rawValue;

        oHidden.fieldcol1.rawValue = oRow.fieldcol1.rawValue;

        oHidden.fieldcol2.rawValue = oRow.fieldcol2.rawValue;

    }

}

var endTime = new Date();

page1hidden.header.ms.rawValue = endTime.getTime() - startTime.getTime();

xfa.host.print(1, "0", (xfa.host.numPages -1).toString(), 0, 1, 0, 0, 0);

form1.page1.printingSF.PrintButton2::postPrint - (JavaScript, client)

page1.presence = "visible";

page1hidden.presence = "hidden";

var oNodes = page1hidden.Table1._Row1.count -1;

for (var j=0; j<=oNodes; j++)

{

    xfa.resolveNode("page1hidden.Table1.Row1[0]").instanceManager.removeInstance(0);

4 Replies

Avatar

Level 10

Hi,

You probably need to publish your form so we can have a look, though the last line looks a bit odd, is the space in the "removeI nstance" method name just from pasting the code into this forum?

Regards

Bruce

Avatar

Level 2

Hi Bruce,

I actually got this working with the below code. My only issue now I think is that the line below the table row with the checkbox needs to be hidden as well when it is checked. Below is an example of what I am trying to do. I can't really publish the original without alot of censoring due to the sensitivity. Also, the form will have 2 pages with the print button on the 1st page. It looks like I have to put it on the same page with the checkboxes though. Any ideas how I can make it work?

example.jpg

---------------------------------------------------------------------------

form1.page1.printingSF.PrintButton2::click - (JavaScript, client)

for (var i=0; i<=23; i++)

{

    var oRow = xfa.resolveNode("Table1.Row1[" + i + "]");

    if(oRow.checkcol.rawValue == "0")

    {

        oRow.presence = "hidden";

    }

}

xfa.host.print(1, "0", (xfa.host.numPages -1).toString(), 0, 1, 0, 0, 0);

form1.page1.printingSF.PrintButton2::postPrint - (JavaScript, client)

for (var i=0; i<=13; i++)

{

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

}

------------------------------------------------

Avatar

Level 10

Hi,

Since you have a reference to the row, you can refer to the next row using a SOM expression with a relative index, so;

for (var i=0; i<=23; i++)
{
    var oRow = xfa.resolveNode("Table1.Row1[" + i + "]");
    if(oRow.checkcol.rawValue == "0")
    {
        oRow.presence = "hidden";
        var oNextRow = oRow.resolveNode("Row1[+1]");
        oNextRow.presence = "hidden";
    }
    break;
}

and then a similar thing on the postPrint

Bruce

Avatar

Level 2

Thanks Bruce, I will try this out. I appreciate your assistance.