Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

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;
              }
         }
    }
}
share|improve this question
add comment

1 Answer 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.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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