点击形状上的sharepoint javascript

时间:2013-03-25 17:18:57

标签: javascript sharepoint onclick shape visio

我需要在SharePoint中的Visio中添加一个onclick事件,使用JavaScript,就像vwaControl处理程序shapeselectionchanged一样,但是点击,有什么方法可以做到吗?

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

我希望你能理解我。

1 个答案:

答案 0 :(得分:1)

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

请参阅: Programming with Visio in SharePoint, create new Outlook meeting in ?Javascript?

请参阅: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;        
}