4

I have a Document Library that is grouped by a column "Meeting Name." I should note that this code works on the other Document Libraries, just does not when the grouping is applied. Any suggestions would be appreciated. Thanks!

!(http://imgur.com/krRSI.PNG)

I've tried the following two methods for getting the pdf to open in a new browser window, but both fail:

_spBodyOnLoadFunctionNames.push("OpenPDFNewWindow");
function OpenPDFNewWindow() 
{
    var aAllLinks = document.links;
    for(var i=0;i<aAllLinks.length;i++)
    {
        var oA = aAllLinks[i];
        var sHREF = oA.href.toLowerCase();
        if(sHREF.indexOf(".pdf") > 0)
        {
             oA.onclick=function()
             {
                 var w = window.open(this.href);
                     if(w) {
                         w.focus();
                         return false;
                      };
                 return true;
              }
         }
    }
}

1 Answer 1

1

When grouping is enabled on SharePoint list view, it does not load information on page load, but do an ajax loading later on group expanding. That is why it works on other standard views without grouping.

So when your javascript runs, there is no links on the page to change. You need somehow to run your script after expand event happened to get it working.

Alternatively you might consider an option to adjust xslt template for view and add onclick attribute there instead of using javascript.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.