I'm having trouble loading jQuery into SQL Server Reporting Services
Report Manager.  Since SSRS is a proe-compiles ASPX

page, and we are not given the source code, we have little ability to
make changes to the interface.  If I could add jQuery

directly, the progblem would be trivial.  However, all we have the
ability to modify is an existing Javascript file that is

loaded at runtime in the head of each page.

I have been able to get this to load relatively reliably using IE 8,
but other browsers either don't load it at all, or

only on the first pass.

Here is the structure that I have in place:

1.  Each page load /Reports/ReportManager/js/ReportingServices.js:

<head>
        <script language="JScript" src="/Reports/js/ReportingServices.js"
type="text/Javascript"></script>

2.  ReportingServices.js Contains the following lines at the top:

addLoadEvent(SetMultiSelectParamWidth);
addLoadEvent(loadjQueryFile);

function addLoadEvent(fn)
{
    if (window.addEventListener)
       window.addEventListener('load', fn, false)
    else if (window.attachEvent)
       window.attachEvent('onload', fn);
}


function loadjQueryFile()
{
        loadjscssfile("/Reports/js/jquery-1.3.2.min.js", "js"); //dynamically
load and add this .js file
        loadjscssfile("/Reports/js/jQueryPageCommands.js", "js");  //
dynmically load the js Page Commands
}

function loadjscssfile(filename, filetype){
 if (filetype=="js"){ //if filename is a external JavaScript file
  var fileref=document.createElement('script')
  fileref.setAttribute("type","text/javascript")
  fileref.setAttribute("src", filename)
 }
 else if (filetype=="css"){ //if filename is an external CSS file
  var fileref=document.createElement("link")
  fileref.setAttribute("rel", "stylesheet")
  fileref.setAttribute("type", "text/css")
  fileref.setAttribute("href", filename)
 }
 if (typeof fileref!="undefined")
  document.getElementsByTagName("head")[0].appendChild(fileref)
}

The first addLoadEvent is for a user interface modification for SSRS
itself.  The second loads the jquery system as well as

some jquery commands.

I understand that there is some discussion that the addLoadEvent that
I am using will wipe out an existing LoadEvent.  I

also understand that Simon Willison has specified a more reliable
loader at

http://simonwillison.net/2004/May/26/addLoadEvent/  -- however, when I
try that version, I don't seem to get it to load at

all.  Willison's code looks like:

function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      oldonload();
      func();
    }
  }
}

3  The jQueryPageCommands contains:

   $(document).ready(function(){
        $("a:contains('Test 1')").attr('href','http://www.google.com');
   });

Which I use as a test to modify a URL.  On the browsers that this
works on, the URL is modified as requested.

Some of the things that I have been thinking about:

1.  Switch to the googleapu method of loading jquery.
2.  trying to get Simon Willison's addLoadEvent to properly work.
3.  Trying to load fewer js files into Head, and seeing if I can load
some of this stuff inline
4.  Finding an already used inline function that is running in SSRS on
each page, and trying to stuff my code into that.
5.  Decompile Report Manager and try to rebuild it myself.

Any ideas or recommendations would be gladly accepted.

Walt Crosby
VP of Development
Interval Data Systems, Inc.

Reply via email to