0

我需要使用 JavaScript 将 onclick 事件添加到 SharePoint 中的 Visio 中的形状,例如 vwaControl 处理程序 shapeselectionchanged 但在单击时,有什么办法可以做到吗?

我很抱歉我的英语不是我的母语。

我希望你能理解我。

4

1 回答 1

1

我只是做了类似的事情。您可以使用 shapeSelectionChangedHandler 来处理点击。据我所知,没有 onClick 功能,但 shapeSelectionChangedHandler 对我来说效果很好。

请参阅: 在 SharePoint 中使用 Visio 进行编程,在 Javascript 中创建新的 Outlook 会议?

请参阅:http: //msdn.microsoft.com/en-us/library/gg243427.aspx以获取使用 Content WebPart 等进行设置的指南。

我使用的代码,只需添加你想要的shapeSelectionChangedHandler = function(source, args) {}

<script language="javascript">
var app = Sys.Application;

app.add_load(onApplicationLoad);

// hold an instance of the Visio VWA control
var vwaControl; 

var shapeSelectionChangedHandler = null;


function onApplicationLoad()
{
    vwaControl= new Vwa.VwaControl("WebPartWPQ4");
    vwaControl.addHandler("diagramcomplete", onDiagramComplete);
    vwaControl.addHandler("shapeselectionchanged", shapeSelectionChangedHandler);
}

function onDiagramComplete()
{
    var vwaPage = vwaControl.getActivePage(); 
    vwaPage.setZoom(35); // force the initial zoom level
}


shapeSelectionChangedHandler = function(source, args)
{
    // get the selected shape from the shapes on the page
    var vwaPage = vwaControl.getActivePage(); 
    var vwaShapes = vwaPage.getShapes(); 
    var shape = vwaShapes.getItemById(args);

    // get the data to display for the selected shape
    var data = shape.getShapeData();

    var strRoomName = ""; 
    var strFloorNumber = "";
    var strCapacity = ""; 
    var strStatus = ""; 

    for (var j = 0; j < data.length; j++)
    {
        if (data[j].label == "RoomName")
        {
            strRoomName = data[j].value;
            continue;
        } 

        if (data[j].label == "FloorNumber")
        {
            strFloorNumber = data[j].value;
            continue;
        }

        if (data[j].label == "Capacity")
        {
            strCapacity = data[j].value;
            continue;
        }        

        if (data[j].label == "RoomStatus")
        {
            strStatus = data[j].value;
            continue;
        }                
    }

    // get the selected state input and set its value
    var  inputRoomName = document.getElementById('strRoomName');
    inputRoomName.value = strRoomName;

    var inputFloorNumber = document.getElementById('strFloorNumber');
    inputFloorNumber.value = strFloorNumber;

    var inputCapacity = document.getElementById('strCapacity');
    inputCapacity.value = strCapacity;    

    var inputStatus = document.getElementById('strStatus');
    inputStatus.value = strStatus;        
}
于 2013-03-26T10:39:16.400 回答