I need to loop thru my instances and toggle visible/hidden if a particular radio button in each instance is selected.
My code right now does not work but I feel I am on the right track (minus the else statement it will need to toggle on/off).
Can anyone help? thanks in advance!
var rowCount = BugGroup_f.instanceManager.count;
for (i=0; i<rowCount; i++) {
var str = xfa.resolveNode("BugGroup_f.detail3.bugInfo.BugItem.status.RadioButtonList[" + i + "]").rawValue;
if (str.indexOf("Fixed") > -1) {
xfa.resolveNode("BugGroup_f["+rowCount+"]").presence = "hidden"
}
}
Solved! Go to Solution.
Views
Replies
Total Likes
Yup, though the exact logic of which are hidden or unhidded can be tweeked however you like.
That exact code will hide(or leave hidden) any row whos radio button is set for hiding. And will allow you to call it with a reset value (1) that will unhide all rows reguardless.
if you want other logic than that, it's just a question of what you put inside the for loop, and can be as complex as you like.
EDIT:
To add a script object, Right-Click on the top form in the hierarchy window, and pick "add script object."
It will make an unnamed object down below (under "variables") and you can put any code in there that you like, in the form of "functions."
then to run the code you reference the Function by name from some form event, and you're off to the races, so to speak.
Views
Replies
Total Likes
You might be able to use this since I've simplified it a bit from what we use. We have a field called 'policyType' wrapped in a subform called 'subOtherInsuranceDetail'. This subform is wrapped in a subform called 'subOtherInsuranceList'. We need to find the number of instances of 'policyType' that contain a string 'aString'.
var otherDetailLines = subOtherInsuranceList.resolveNodes("subOtherInsuranceDetail[*]");
for (i = 0; i < otherDetailLines.length; i++)
{
if (otherDetailLines.item(i).resolveNode("policyType").rawValue != "aString")
{
otherUncompleteRows = otherUncompleteRows + 1;
}
}
Remember that the count is 1 based but the instances are 0 based ......so you will have to subtract 1 from the count to get the correct instance that you want.
paul
Ok great! My row instance is named BugGroup_f. My radio button group is 4 subforms deep within this. My updated code looks like this but is only changing which radio button is selected. It does not seem to be hiding the instances.
var otherDetailLines = xfa.resolveNodes("BugGroup_f[*]");
for (i = 0; i < otherDetailLines.length; i++)
{
if (otherDetailLines.item(i).resolveNode("employees.P1.BugGroup_f.detail3.bugInfo.BugItem.status.RadioButtonList").rawValue = "2")
{
otherDetailLines.presence = "hidden";;
}
}
Message was edited by: malaki - I was able to tweak something which got me closer. I changed the var
Views
Replies
Total Likes
Check you're IF statement conditional there. ; )
Additionally, I think there's a much much easier way to do the object referencing, but give me a couple minutes to type that up.
EDIT:
Let me double check what it is you are trying to do: you want one radio button in each row to be able to hide that row?
so
Row object
L Radio button
and flipping the button turns off it's own Row object and no others?
Views
Replies
Total Likes
Even closer now: My code is looping through and hiding the right rows but now i cannot unhide them. any help?
var otherDetailLines = xfa.resolveNodes("BugGroup_f[*]");
for (i = 0; i < otherDetailLines.length; i++)
{
if (otherDetailLines.item(i).resolveNode("BugGroup_f.detail3.bugInfo.BugItem.status.RadioButtonList").rawValue == "6")
{
otherDetailLines.item(i).presence = "hidden";
}
else if (otherDetailLines.item(i).resolveNode("BugGroup_f.detail3.bugInfo.BugItem.status.RadioButtonList").rawValue != "6")
{
otherDetailLines.item(i).presence = "visible";
}
}
Views
Replies
Total Likes
So we've got a set of Rows, each with a subitem called RadioToggle, and you want to go through and set them all, then click a separate button and hide the ones with "on" radio buttons?
function ToggleRows(reset){
var Rows = Form.subform....BugGroup_f.all;
var curRow;
for (var i=0; i<Rows.length; i++){
curRow = Rows.item(i);
if ((curRow.RadioButton.rawValue == "WhatevermeansHidden") && !reset){
curRow.presense = "hidden";}
else{
curRow.presense = "visible";}
}
}
^ in a script object, and put
scriptObjectName.ToggleRows(reset);
in the click event of your button, and you should be golden.
If you do want them to hide the moment you click the toggle, you could put this, right?
if (xfa.event.newText == "whatevermeansoff"){
parent....presense = "hidden";}
The .all method seems like a much easier way to handle collections of objects, and specificaly collections of instances. It also means you can do relative referencing, i.e. to create a function that will operate on all the rows of a table, without knowing which table it is operating on, so a button in each table can pass it's parent table to the function.
var GroupVariable = Object.all
for(var i=0; i < GroupVariable.length; i++)
EDIT:
add a reset value, and pass it in to your function like above (added).
make a separate button, or control, that will call the function with reset = 1.
Views
Replies
Total Likes
Thanks for the assistance. I want to make sure we are on the same page before I attempt your solution.
Click a button which will:
1. Go through all rows and CHECK them all for a particular value in a radio button group
2. Hide/unhide the ones with that found value (depending on thwir current presence state)
PS What is a script object?
Views
Replies
Total Likes
Yup, though the exact logic of which are hidden or unhidded can be tweeked however you like.
That exact code will hide(or leave hidden) any row whos radio button is set for hiding. And will allow you to call it with a reset value (1) that will unhide all rows reguardless.
if you want other logic than that, it's just a question of what you put inside the for loop, and can be as complex as you like.
EDIT:
To add a script object, Right-Click on the top form in the hierarchy window, and pick "add script object."
It will make an unnamed object down below (under "variables") and you can put any code in there that you like, in the form of "functions."
then to run the code you reference the Function by name from some form event, and you're off to the races, so to speak.
Views
Replies
Total Likes
Views
Likes
Replies