Using jQuery in MicroStrategy Dashboards

I’ve written about a lot of cool things you can do with HTML Containers, but the best involve JavaScript because they add a new level of interaction to MicroStrategy.  Now it’s time to take that to the next level with jQuery, a free, open source library of functions that not only automate a ton of cool features for you but also whittles down the syntax to be super light and easy to maintain.  You can implement this without any customizations which is extremely powerful and it really opens up your imagination for what you can accomplish with MicroStrategy.  Of course, these new found powers will only work on Web, though they also work on Mobile Web Browsers, but not the Mobile App itself.

Loading the jQuery Library
The first step is to load the jQuery Library into MicroStrategy.  This can be done one of two ways, each with some advantages and disadvantages.

Load the library via an HTML Container
You can simply include the code to import jQuery right into the HTML Container you’re going to call it from.  The script to do this is:

<script type="text/javascript" src="http://code.jquery.com/jquery-1.9.1.min.js"></script>

The advantage to using this method is that it requires zero plugins.  Also, the library can be large (you can also try the .min. version if you experience loading problems on older machines), so choosing to only load it on Documents that specifically need it can be a good choice.

Load the library via a plugin
You can modify the mstrWeb.aspx and Mojo_Section.aspx (for Express mode) pages and simply add the <script> tag after the <head> tag, and now it’ll be globally loaded.

The advantage here is a slightly cleaner looking HTML Container that makes debugging a little easier, as well as no need to remember or store that command.  Also, if you need to upgrade the version you’re using, then having a single reference makes that easier.

Referencing the .js file
My examples show a direct cross site link.  Doing this could potentially add some delay or outage if the jQuery site is having trouble.  Due to the nature that they roll these out, there isn’t any source control advantage to do it this way (meaning, any updates will be delivered in the form of new versions, not updated in line).  As such, the best approach is probably to download a copy of the script to your server and reference it locally, like this:

<script type="text/javascript" src="../local/jquery.min.js"></script>

This does require a few extra setup steps that you may or may not have access to, but you can try it out using the direct link (if your web server allows cross site scripting) before going through the trouble of moving files around.

What can you do with jQuery?
The most fundamental function you can do is execute JavaScript code on page load.  Without jQuery, I wasn’t able to find any way to accomplish this with traditional JavaScript in HTML Containers.  This has some really powerful effects, as mentioned in the <Collapsible Sections with jQuery> post.

List of all of my jQuery Hacks

Useful Links
jQuery API Documentation
jQuery Tutorials to get your started
jQueryUI if you really want to go crazy

 

You may also like...