Friday, February 28, 2014

Sharepoint 2013 Visio web access webpart scripts (3. Script to set active to perticular page name(Visio sheet name)

function setPage(callingNode) {
    try {
   

var vwaControl;
vwaControl= new Vwa.VwaControl(getVWAWebPartID1());
   


        // Get id from calling DOM node and set the corresponding page.
        vwaControl.setActivePage(callingNode);
    }
    catch(err) {
        alert(err);
    }
}



// Search the SharePoint page to get the WebPartID# for the Visio Web Access Web Part.
function getVWAWebPartID1() {
   
    // Get a NodesList of all the div tags on the page.
    var divArray = document.getElementsByTagName("div");
    var webPartElementID;
   
    // Iterate through the NodesList to get the node with the class attribute "VisioWebAccess."
    for (var i = 0; i < divArray.length; i++) {
        var node = divArray[i];
       
        // Return the first instance of the Visio Web Access Web Part.
        if (node.className == "VisioWebAccess") {
            webPartElementID = node.parentNode.parentNode.id;
            break;
        }
    }
    return webPartElementID;
}

Note: Now when ever we want to set particular page name as active, we will just pass the name of the page(visio page) to that script.
Ex:
onclick= "javascript:setPage('visio page sheet name')");

No comments:

Post a Comment