Expand my Community achievements bar.

SOLVED

Hide all instances of subform with one line of javascript

Avatar

Level 3

Is it possible to hide all instances of a subform with a single line of javascript?  I'm trying something like this:

    repeatingSubform[*].presence = "hidden";

but that causes designer to crash...

Or, must I loop through all instances of the subform and turn each one off individually?

Thanks,

Elaine

1 Accepted Solution

Avatar

Correct answer by
Former Community Member

You have to turn them off individually

Paul

View solution in original post

6 Replies

Avatar

Correct answer by
Former Community Member

You have to turn them off individually

Paul

Avatar

Level 3

another javascript common method to hide all instances of a subform:

//parameters:

//subform: string containing the subform name - fully qualified i.e. parent.parent.subform...

//presenceSetting:  string containing the text "hidden" or "visible"

function changeDynamicSubformPresence(subform, presenceSetting)
{
    numInstances = xfa.resolveNode(subform).instanceManager.count;
    for (var i=0; i<numInstances; i++)
    {
        xfa.resolveNode(subform + "[" + i + "]").presence = presenceSetting;   
    }   
}

calling the method:

    formScript.changeDynamicSubformPresence("subformName", "hidden");

--Elaine

Avatar

Level 2

Of course, you can wrap the repeating subforms in a parent subform and then hide the parent with one line of code

Ben Walsh

www.avoka.com

Avatar

Level 3

Oh, you sneaky little avoka-devil, you. Very clever. I'll remember

that next time, I already wrote the "looping" code

Thanks Ben!

Elaine

Avatar

Level 3

This answer was helpful but I have a new question about this: How would one loop through the instances and turn off depending on a condition?

So upon a click event loop through all instances, if a certain radio button is selected hide that row and leave the others alone?

Thank you.

Avatar

Level 3

I am popping out of here into a new posting.

The following has evaluated to null or missing: ==> liqladmin("SELECT id, value FROM metrics WHERE id = 'net_accepted_solutions' and user.id = '${acceptedAnswer.author.id}'").data.items [in template "analytics-container" at line 83, column 41] ---- Tip: It's the step after the last dot that caused this error, not those before it. ---- Tip: If the failing expression is known to be legally refer to something that's sometimes null or missing, either specify a default value like myOptionalVar!myDefault, or use <#if myOptionalVar??>when-present<#else>when-missing. (These only cover the last step of the expression; to cover the whole expression, use parenthesis: (myOptionalVar.foo)!myDefault, (myOptionalVar.foo)?? ---- ---- FTL stack trace ("~" means nesting-related): - Failed at: #assign answerAuthorNetSolutions = li... [in template "analytics-container" at line 83, column 5] ----