Ewa.EwaControl.add_gridSynchronized(function)
Applies to: apps for SharePoint | Excel Services | SharePoint Server 2013
In this article
Return Value
Remarks
Example
Adds an event handler to the gridSynchronized event.
Ewa.EwaControl.add_gridSynchronized(function);
Parameters
function
The event handler to subscribe to the event.
Return Value
None.
Remarks
The EwaControl.add_gridSynchronized method subscribes an event handler to the gridSynchronized event.
Note
The grid is the construct that Excel Services uses to display the viewable area of the Worksheet within the Excel Web Access Web Part.
The gridSynchronized event is raised when the grid is finished rendering, when the workbook is loaded or reloaded, or when grid blocks are updated. The event is also raised the first time that the event handler is subscribed to (the grid will have finished rendering before this).
When the specified event handler for the gridSynchronized event is invoked, it is invoked with a single argument of type Ewa.WorkbookEventArgs. The Ewa.WorkbookEventArgs object contains information about the Workbook associated with the gridSynchronized event.
Example
The following code example subscribes an event handler to the gridSynchronized event. The code also shows how to use the Ewa.WorkbookEventArgs to get information about the associated Workbook. The code example assumes that you are working with an Excel Web Access Web Part on SharePoint Server 2013.
<script type="text/javascript">
var ewa = null;
// Add event handler for onload.
if (window.attachEvent)
{
window.attachEvent("onload", ewaOnPageLoad);
}
// Add event handler for applicationReady event.
function ewaOnPageLoad()
{
if (typeof (Ewa) != "undefined")
{
Ewa.EwaControl.add_applicationReady(ewaApplicationReady);
}
else
{
alert("Error - the EWA JS is not loaded.");
}
}
function ewaApplicationReady()
{
ewa = Ewa.EwaControl.getInstances().getItem(0);
// Add event handler for gridSynchronized event.
ewa.add_gridSynchronized(gridSync);
}
// Handle gridSynchronized event.
function gridSync(args)
{
alert(args.getWorkbook().getActiveSelection().getAddressA1());
}
</script>