Running jQuery scripts on PerformancePoint data

I recently had a close encounter with a SharePoint PerformancePoint dashboard page that displayed its data in grids. My task was to calculate row and column totals and display the results in an additional column and row that would be appended to the right and bottom of the grid respectively. I had done something similar before using  jQuery/JavaScript, so without much further ado I proceeded to make a copy from source of the data grid’s generated HTML and write a script that would quickly and neatly do exactly what was required. When I incorporated the script into the dashboard page itself, however, it would not run. A quick test showed that the script worked fine in the console, but was having trouble with page load. This pointed to the probability that the PerformancePoint data was not ready when document ready came around, and that therefore jQuery had no data to work with when it tried to run. I needed an event that would fire when PerformancePoint finished loading, and found it here:


After wrapping the above function around my jQuery, presto magico, it ran like a champ.

On the test page that is. The real production page had three such grids, and thus I found that the script was running three times, and adding a row and a column each time with compounded totals! I would post a screenshot, but I’m certain it would beget a tempest in those gentle souls with finer sensibilities.

And this is where things started to get really interesting. NotifyBrowserOfAsyncUpdate is an obscure function that had to be fished out of the .NET assemblies and for which there is precious little documentation. A colleague of mine and I grappled with this problem for a couple of hours and to make a long story short, came up with a solution that is actually a bit of a hack and which involves a sleeper function that checks for the presence of an HTML element at a given interval:



The interval can of course be adjusted to suit preferences and performance. Perhaps the trickiest part of this effort was figuring out that the calculatetotalrunonce variable had to be attached to the JavaScript window object in order to make it work as a  global variable. For a while there, it was touch and go, but all’s well that ends well.

May 22, 2013