Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
PUBLIC CLOUD
PRIVATE CLOUD
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Web CMS (TeamSite)
Hiding few Items in replicant on (+)
Team
I want to hide few items when i click on (+) Add replicant.
Here is the scenario:
I have 2 textareas - Item1 and item2. When a user clicks on (+) to add a replicant - only Item 1 should be replicated and not item2.
I used OnReplicantAdded event but there seems to be some error due to which i cannot see the effect. I am also using a CONTAINER.
Here is what i have so far:
THE DCT code:
<item name="DText">
<label>Item 1:</label>
<replicant min="1" max="unbounded">
<item name="item1">
<description>Item 1description>
<label>Item 1</label>
<text required="t" size="50" maxlength="500"/>
</item>
<item name="Item2">
<label>Item2</label>
<text required="f" size="50" maxlength="500"/>
</item>
</replicant>
</item>
I added the Formapi Under <Ruleset> but before <container> starts:
<ruleset name="Item Test">
<script>
<![CDATA[
<!-- ===== HIDE SUBHEADER CODE ==== -->
IWEventRegistry.addItemHandler("/DText","OnReplicantAdded",Hide_SubHeader);
function Hide_Subheader()
{
for (var i=1;i<=IWDatacapture.getItem('/DText').getChildren().length;i++)
{
alert("Entering Replicant Event");
IWDatacapture.getItem('/DText[' + i + ']/item2').setVisible(false);
}
}
]]>
</script>
Also if i am using a CONTAINER - Do i have to refer container name somewhere in the URL or IWDATAcapture?
Find more posts tagged with
Comments
Team
Will OnReplicantBeforeAdd work?
JonathonG
I'm not sure I understand the question. You talk about a container, but in the posted code, there are no containers. You say "there seems to be some error" but don't provide any hint of what the error is. Do you have javascript debugging turned on in your browser?
One thing I'll guess. If you have a container around the DCT code you posted, then the address for your replicant item is wrong. It is not "/DText", but rather "/containername/DText".
If that doesn't help, I'd suggest posting the full datacapture.cfg and any error messages you are receiving.
Jonathon
Interwoven Developer
Allstate, Inc.
Team
I did checked at the code . i am using the Containername/DText.
The error i am getting is Function HideItem2 is undefined.
What could be the reason for it? Is there anything I am missing? I am trying to Hide Item 2 whenever a new replicant is added (+).
My Code is as under:
<ruleset name="Text Test">
<script>
<![CDATA[
<!-- ===== HIDE ITEM 2 ==== -->
IWEventRegistry.addItemHandler("/main/DText","onReplicantAdded", HideItem2);
function HideItem2()
{
alert("Entering OnReplicant add");
for (var i=1;i<=IWDatacapture.getItem(/main/DText').getChildren().length;i++)
{
alert("Entering OnReplicant add");
IWDatacapture.getItem('/main/DText[' + i + ']/Item2).setVisible(false);
IWDatacapture.redraw();
}
}
]]>
</script>
<container name="main">
<item name="DText" pathid="key">
<label>Box</label>
<replicant min="1" max="unbounded">
<item name="Item1">
<description>Item1</description>
<label>Item 1</label>
<text required="t" size="50" maxlength="500"/>
</item>
<item name="Item2">
<label>Item 2</label>
<text required="f" size="50" maxlength="500"/>
</item>
</replicant>
</item>
</container>
</ruleset>
Adam Stoller
Try moving the function declaration above the addItemHandler
Also the declaration of HideItem2 should be:
function HideItem2(item)
not
function HideItem2()
The 'item' passed will be the instance of the replicant that was added - which should greatly simplify the code for the function
--fish
Senior Consultant, Quotient Inc.
http://www.quotient-inc.com
Team
Function undefined error was resolved. This reason for this error was mismatched names while registering event and Defining that function.
Thanks a lot Jonathon and other Form contributors as well.
Its resolved now and script is working great.
Team
The Add replicant is working fine but only if i try to remove second item.
If i want to remove first item in the replicant - it gives a runtime error . Thought it still deletes the first item but with a runtime error as follows:
"Can't move focus to the control because it is Invisible, not enabled, or of a type that does not accept the focus."
Does anyone Know a solution for this?
Adam Stoller
I think this is a "known" issue when trying to manipulate the first item in the form - is the item you're trying to hide the first item in the form? or the first item in a container later in the form?
I *think* that if you *define* a hidden item in the form (as opposed to using FormAPI to do it - or maybe it's vice-versa?) that you can get aroud this problem (I recall seeing some threads about this, but I don't remember what the final solution was - sorry)
--fish
Senior Consultant, Quotient Inc.
http://www.quotient-inc.com
Team
This is 4th item in the container. and the 4th item is a replicant which contains these 2 items. And i am trying to remove first item on "OnReplicantAdded" event.
e.:
<item>
<replicant>
<item1> - I want to hide this on 2nd onwards Replicant add(+)
<item2> - This should be replicated on (+)
</replicant>
</item>
Adam Stoller
Can you post the updated code (you said you fixed something since the first post)?
--fish
Senior Consultant, Quotient Inc.
http://www.quotient-inc.com
Team
DCT Code is here:
I want the Item1 to be deleted when (+) is clicked. Item 2 can be replicated. So the issue is now i am getting runtime error if i want to remove Item1. But If i want to remove Item 1 - it still removes it but with a runtime error i mentioned before. thsi is happening only in IE browser - not Firefox.
<script>
<![CDATA[
function HidingItem ()
{
IWEventRegistry.addItemHandler("main/DText","onReplicantAdded", HideItem2);
}
function HideItem2()
{
for (var i=2;i<=IWDatacapture.getItem('/main/DText/').getChildren().length;i++)
{
IWDatacapture.getItem('/main/DText/[' + i + ']/Item1').setVisible(false);
IWDatacapture.redraw();
}
}
IWEventRegistry.addFormHandler("onFormInit", HidingItem);
]]>
</script>
<container name="main">
<item name="DText">
<replicant min="1" max="unbounded">
<item name="Item1">
<text required="t" size="50" maxlength="500"/>
</item>
<item name="Item2">
<text required="f" size="50" maxlength="500"/>
</item>
</replicant>
</item>
Edited by Team on 01/19/06 01:21 PM (server time).
Adam Stoller
and 'main' is not the first item in your DCT structure? (if it is, see my previous response)
If it isn't - I suggest contacting support (you may still find the answer here - but it makes sense to log this as a case with them to see if they can reproduce the problem)
--fish
Senior Consultant, Quotient Inc.
http://www.quotient-inc.com
Team
main is the container. Its not the item. i have just pasted the code related to the problem but there are other items also in the DCT before and after the replicant (which is in question.)