Ewa.EwaControl.getDomElement()

Applies to: apps for SharePoint | Excel Services | SharePoint Server 2013

In this article
Return Value
Remarks
Example
Applies To

In Web Part mode, gets the root-level DOM element (HTTPDivElement) for the Excel Web Access Web Part.

var value = Ewa.EwaControl.getDomElement();

Return Value

Object

Remarks

The EwaControl.getDomElement method returns an object that represents the HTTPDivElement that demarcates the Excel Web Access Web Part.

Once you have a reference to the div element that represents the Excel Web Access Web Part, you can perform document object model (DOM) manipulations on it.

Example

The following code example shows how to use the EwaControl.getDomElement method to change the borders of the Excel Web Access Web Part that finishes recalculating first. The code example assumes that you are working with an Excel Web Access Web Part on SharePoint Server 2013.

<script type="text/javascript"> 

// Set a flag for the EWA that recalculates first.
var firstToRecalc = false;

// Declare variables for each EWA.
var Ewa0 = null;
var Ewa1 = null;

// Add event handler for onload event.
if (window.attachEvent) 
{ 
    window.attachEvent("onload", ewaOnPageLoad);    
} 
else 
{ 
    window.addEventListener("DOMContentLoaded", ewaOnPageLoad, false); 
}

// Proceed to the onApplicationReady function once the Excel Services JSOM is ready.
function ewaOnPageLoad()
{
    Ewa.EwaControl.add_applicationReady(onApplicationReady);
}

function onRecalc(asyncresult)
{
    // Use the user context here to get an instance of the EWA.
    currentEwa = asyncresult.getUserContext();

    // Get the root div element for the EWA.
    enclosingdiv = currentEwa.getDomElement();

    // Highlight the border of the first EWA to recalculate.
    if (firstToRecalc == false)
    {
// Change the border of the EWA div.
enclosingdiv.style.border = "solid green 2px";
    }
    // Toggle the flag.
    firstToRecalc = !firstToRecalc;
}

function onApplicationReady()
{
    // Get a reference to the 2 EWAs.
    Ewa0 = Ewa.EwaControl.getInstances().getItem(0);
    Ewa1 = Ewa.EwaControl.getInstances().getItem(1);

    // Call recalcAsync on each EWA part.
    Ewa0.getActiveWorkbook().recalcAsync(onRecalc, Ewa0); // Note the Ewa instance is passed as the userContext.
    Ewa1.getActiveWorkbook().recalcAsync(onRecalc, Ewa1); // The same method is used for both EWAs.
}
</script>

Applies To

Ewa.EwaControl Object

See also

Concepts

Ewa.EwaControl Methods

Ewa namespace