Question

I am trying to find a solution or better way to doing it, basically I have Visio Web Access webpart in the page itself, due to the page layout it only display in small form, we decided to have a button to click on and expand it in full mode, I aware that using the based VisioWebAccess.aspx to call the visio file but we doesn't want the toolbar button to shown.

Questions: Is there any querystring for the VisioWebAccess.aspx that can be use? Or is there anyway for sharepoint modal dialog to inject some javascript?

Code as such:

// Hook into the AJAX Sys.Application.load event.
Sys.Application.add_load(onApplicationLoad)

// Define global variables.
var vwaControl; 
var webPartElementID;
var drawingURL ;
var vwaPage;

// Capture a reference to the current session of the Visio Web Access Web Part.
function onApplicationLoad() {
    try{
            webPartElementID = getVWAWebPartID();
            vwaControl= new Vwa.VwaControl(webPartElementID);
            drawingURL = vwaControl.getDiagramUrl();
            vwaPage = vwaControl.getActivePage();
    }
    catch(err){
        console.log(err);
        $("#btn_visioModal").hide();
    }
}

// Search the SharePoint page to get the WebPartID# for the Visio Web Access Web Part.
function getVWAWebPartID() {

    // 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;
}
function openInDialog() {
try{
    // Get the URL for the drawing currently displayed in the Visio Web Access Web Part.                 
    drawingURL = vwaControl.getDiagramUrl();

    // Setup option for the modal dialog            
    var options = {url: "http://sharepointportal/_layouts/15/VisioWebAccess/VisioWebAccess.aspx?id="
    +  drawingURL,
    width: 1280,
    height: 768,
    allowMaximize: false,
    showClose: true};

    SP.SOD.execute('sp.ui.dialog.js', 'SP.UI.ModalDialog.showModalDialog', options);
}
catch(err){
    console.log(err);
}

Thanks.

Was it helpful?

Solution

Seems like I have found myself a solution: Instead of using VisioWebAccess page, create a new blank page with just the Visio Web Part, use container-fluid if your sharepoint site have bootstrap (which mine has), when calling the modal pass in the file url via querystring and at the modal page include this scrpt:

function changeUrl(){   
    // Get the URL of the current file being displayed.
    fileURL = GetQueryStringParams('fileURL');
    var currDiagram = vwaControl.getDiagramUrl();
    currDiagram = currDiagram.replace("%20", " ");
    fileURL = decodeURI(fileURL);
    console.log(vwaControl.getDiagramUrl());
    console.log(fileURL);
    // Replace the currently displayed Web Drawing with the other Web Drawing.
    vwaControl.openDiagram(fileURL);
}
Licensed under: CC-BY-SA with attribution
Not affiliated with sharepoint.stackexchange
scroll top