Thursday, July 15, 2010

Update to the Javascript Grid Editor: 1.0.10 (Now with improved initialization!)

There come a time when every developer finds new, improved ways of doing things.  I'm no exception to this, and when I learn something new, I try to implement it wherever I may find it beneficial.

Today's study is about the use of Javascript to dynamically load and initialize script and CSS from external files:

Originally, the Javascript Grid Editor used an asynchronous method of achieving this for both external Javascript and CSS files.  While this worked, it was terribly slow, as each script file was loaded and processed by IE asynchronously, each reporting back to a shared handler that check the status of all outstanding resources.  Crude, but effective.  What it was not, however, was efficient.

Because of the way I was hacking together CRM controls for the JGE, I required these external sources to load before proceeding to implement the controls.  Most users of the JGE experienced this requirement by way of a load time that was either very long, or didn't work at all!  That said, I had been on the lookout for a better method of synchronously loading these scripts without using the dreaded eval() statement.

Today is the day I found it.  Thanks to a very thorough posting by Stoyan Stefanov, I was able to make both the external Javascript and external CSS files load in a synchronous manner, thereby improving the responsiveness and initialization times of the JGE incredibly.  This marks the resolution of a particularly troubling bug I've dealt with in my own deployment.

If you found that the JGE hadn't worked properly for you in the past, I encourage you to grab the latest release.

[ADDENDUM: I've also included the altered code in the IncludeScript(), IncludeStylesheet(), IncludeExternalScript(), and IncludeExternalStylesheet() functions in the CRM Javascript Library.]


  1. Does this version work with money attributes?

  2. No support for the money fields yet. I'm working on a 1.1 version of this project which will address money fields and special entities, like the Quote/Order/Invoice Product. This release was unscheduled, and became escalated above my current development line because it did address a serious issue with the script not working in some situations, as Adi Katz succinctly outlined in the blog posting to which I linked in the post above.

    Sorry for the delays with these features, fellas. Unfortunately, if I can't justify developing it for my employer (which I can't yet), then I'm stuck doing it after-hours, and I have a 1 year-old who takes precedence--so the going is terribly slow.

  3. Thank you for the update Dave.

  4. Dave your hard work was appreciated. Thanks for all your tools and contribution :)

  5. Hi Dave,

    Great work, thanks for sharing. I think it's great you've came up with a third way of loading js (the others being append script src or ajax and eval).

    Do you have any metrics between the script load times of using the eval method vs you'ur ajax and append to dom method.

    Kind regards
    Simon Jackson

  6. That would be an interesting thing to accomplish. I don't believe I have a proper testing environment (meaning a clean, unfettered system) for testing javascript execution metrics. The solution I used was meant to overcome certain hurdles or performance problems in the other methods. I remain 99% certain that my method is at least faster than using eval(), and it's much more stable (and faster) in my direct experience than the appended "<script src=" model. Also, it allows my script inclusions to run synchronously--which only eval() offered.

  7. Hi Dave,
    Can you please let me know if your JGE will work when we migrate to 2011?

  8. I intend to try it myself soon, but before upgrading it for 2011, I wanted to see what other options exist. The new "Solutions" for CRM 2011 changes the game for utilities like this dramatically, not just the complete overhaul of the DOM and JS elements. Those two things will probably make the solution incompatible with CRM 2011.

    I've seen a grid editor recently on the new Dynamics Marketplace that I felt was pretty compelling... uncertain of the price though. My life became infinitely more complicated with the advent of my daughter's cancer, so every mote of progress I was making toward patching out the last known bugs, and upgrading the project to 2011 has all but flown out the window.

    One of the chief reasons I made this project open-source, was to encourage a collaborative development that would help carry the project forward. However, the relative lack of interest to-date leaves me the sole developer... so for what's it's worth, I do apologize for the state of things.

  9. No worries Dave. God bless your daughter. Take care!


Unrelated comments to posts may be summarily disposed at the author's discretion.