logo

Previous Thread:   Roles and conditional formatting

1/16/2006 8:03:01 PM    Switch view programmatically
I'm trying to switch view depending on the attribute of the XML document  
  
being passed to InfoPath.  
  
The name of the view is stored as an attribute (openView) on the root node.  
  
I have the following code in the OnLoad event.  
  
function XDocument::OnLoad(eventObj)  
  
{  
  
var rootNode = XDocument.DOM.selectSingleNode("/my:myFields");  
  
var openView = rootNode.getAttribute("my:openView");  
  
XDocument.View.SwitchView(openView);  
  
}  
  
The variable openView is being read correctly but the SwitchView is not  
  
working.  
  
Anyone with any bright ideas why? I suspect that the view is not available  
  
in the onLoad event. If not, where else can I have it?  
  
Thanks



1/17/2006 10:27:27 AM    Re: Switch view programmatically
In the onload handler you must do it a little differently because the =  
  
View object doesn't yet exist.  
  
XDocument.ViewInfos(openView).IsDefault =3D true;  
  
--=20  
  
Greg Collins [InfoPath MVP]  
  
Visit http://www.InfoPathDev.com  
  
"sunflower" <sunflower@discussions.microsoft.com> wrote in message =  
  
news:32E8F251-637F-4741-9A77-76A215ECB641@microsoft.com...  
  
I'm trying to switch view depending on the attribute of the XML document =  
  
being passed to InfoPath.  
  
The name of the view is stored as an attribute (openView) on the root =  
  
node. =20  
  
I have the following code in the OnLoad event.  
  
function XDocument::OnLoad(eventObj)  
  
{  
  
var rootNode =3D XDocument.DOM.selectSingleNode("/my:myFields");  
  
var openView =3D rootNode.getAttribute("my:openView");  
  
XDocument.View.SwitchView(openView);  
  
}  
  
The variable openView is being read correctly but the SwitchView is not=20  
  
working.  
  
Anyone with any bright ideas why? I suspect that the view is not =  
  
available=20  
  
in the onLoad event. If not, where else can I have it?  
  
Thanks