CRM 2011–Excessive Sub-Gridding by

Sub-grids enhance the user experience by conveniently providing associated information.  Within a sub-grid the user can easily view, create, or modify a related entity.  By default, Microsoft will auto-populate up to four sub-grids. 



One thing to note however is that if the form contains more than four sub-grids, then sub-grids 5+ will contain a message inside the sub-grid “To load x records, click here”.  To populate the sub-grid, the user has to click the refresh button or the link.



CRM 2011 does this intentionally to make sure the User is presented with the Form as quickly as possible.  Each sub-grid is another Fetch call to the database, so reducing those inherently speeds up the form. 

Now what if you only need a few more sub-grids and you are ok with the potential performance trade-off?  Well, let’s add a little JavaScript to auto load all of our sub-grids that didn’t auto load already:

function getLinksWithClassName(classname)  {
    var bdy = document.getElementsByTagName("body")[0];
    var els = [];
    var re = new RegExp('b' + classname + 'b');
    var lnks = bdy.getElementsByTagName("a");

    for(var i=0,j=lnks.length; i<j; i++)

    return els;

var lnksUnloaded = getLinksWithClassName('ms-crm-List-LoadOnDemand');

for (var i = 0; i < lnksUnloaded.length; i++){


Now adding the bottom four lines to our OnLoad event will cause all of our sub-grids to auto-load.  Hope you enjoy!