Switch view programmatically

S

sunflower

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:eek:penView");

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
 
G

Greg Collins [InfoPath MVP]

In the onload handler you must do it a little differently because the View object doesn't yet exist.

XDocument.ViewInfos(openView).IsDefault = true;

--
Greg Collins [InfoPath MVP]
Visit http://www.InfoPathDev.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.
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:eek:penView");

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top