I find it difficult to swallow there isn't a way to set the visiblity property inline with the data capture item so that replicant's children are spawned in the correct visibility without needing an event handler to loop trough each time a new repliacant is added.
This was my solution to what I think you are saying. I know this was posted in 2003 but maybe it will help someone.
My setup is this:
I have a list of "alerts" and each "alert" can have multiple "sections" to it. The "sectionType" is either "full width" (one column) or "two column" decided by a radio button. Full width is on by defualt so the extra text area for the second column should be hidden by defualt.
on startup loop through and set visibility for every instance to match the radio setting. Then have event handlers for when the toggle is changed by user and also each time the user ads a new instance of an iterator so they default correctly.
// add event handlersIWEventRegistry.addItemHandler("/alerts/alert/section/sectionType", "onItemChange", typeHandler);IWEventRegistry.addItemHandler("/alerts/alert/section", "onReplicantAdded", addSectionHandler);IWEventRegistry.addItemHandler("/alerts/alert", "onReplicantAdded", addAlertHandler);// go through and hide/show second content area for all full width sections in all alerts.var i = 1; var alertItem;while (alertItem = IWDatacapture.getItem("/alerts/alert[" + i + "]")){ var j = 1; var section; //alert (alertItem.getName() ); while (section = IWDatacapture.getItem(alertItem.getName() +"/section[" + j + "]")) { //alert (section.getName() ); addSectionHandler(IWDatacapture.getItem(section.getName() )); j++ } i++}// hide/show second content area for all full width sections in alerts just added.function addAlertHandler(alertItem) { var i = 1; var section; while (section = IWDatacapture.getItem(alertItem.getName() +"/section[" + i + "]")) { //alert (section.getName() ); addSectionHandler(IWDatacapture.getItem(section.getName() )); i++ } return}// hide/show second content area for new full width sections just added.function addSectionHandler(section) { typeHandler(IWDatacapture.getItem(section.getName() +"/sectionType")); return}// hide/show second content area when toggle is clickedfunction typeHandler(type) { var itemContent2 = IWDatacapture.getItem(type.getName() +"/../sectionContent2"); if(type.getValue()){ //alert ("Two column on"); itemContent2.setVisible(true); }else { //alert ("Two column off" ); itemContent2.setVisible(false); }}
Maybe a better way to do it. My coding isn't great.
I just really wish there was a way to set visiblity inline like css's display property. Would be so much easier since then you'd only need the radio change event.
This is not rocket science. Not sure why you felt the need to resurrect a 13 year old post to inject what is basically Forms Publisher 101.
David,
Everyone starts somewhere. I'm not sure why you wasted your time reading this if you know forms publishing so well.
Greg
kaplag wrote: David, Everyone starts somewhere. I'm not sure why you wasted your time reading this if you know forms publishing so well. Greg
I would have posted a new thread instead of replying to a 13 year old thread, If you have a question whether you are doing something correct, post the problem and how you have attempted to solve it and people may reply.
The formatting on the old threads (from different BBS) is so bad I seldom even read them .
hey Andy,
I appreciate the explination and will do that next time.
To add a little more to this topic, I discovered that this works:
<item name="repChild" pathid="repChild" visible="f"> <label>Will be invisible on load</label> <text /></item>
I didn't see anything about this in the Template dev or Form API documentation. The API can be used to set it visible when needed. I think this removes the need for an onReplicantAdded event handler in this particular use case.
Yea. The original templating solution didn't have FormAPI so readonly, visible, hidden, etc were all written in the DCT. When FormAPI was introduced, the DCT functionality stayed. IIRC, FormAPI cannot override the hard DCT setting.