2

does anybody know a simple way to make the listview of a document library link to an item (dispform not editform) instead of opening the document on click?

Thanks in advance!

3 Answers 3

1

You can add a link to display form by creating new text column on a list and setting following properties on it from code or PowerShell: LinkToItem and LinkToItemAllowed. I don't think those options are available anywhere in GUI in SharePoint 2013.

Example:

 SPField field = spList.Fields.GetFieldByInternalName(fieldInternalName);
 field.LinkToItemAllowed = SPField.ListItemMenuState.Required;
 field.LinkToItem = true;
 field.Update();

Doing it this way you don't need Event Receiver.

It seems however that the link generated this way doesn't care about list's settings on whether to open forms in a popup or a page (and always just generates link to a page).

Also, there'sa similar question now: sp2013: Column with link to the displayform like on the title column?

I know this is an old question, but with SharePoint 2013 and Online people might still stumble upon similar problem :)

1

There is also another option (in 2013) where you can use CSR.

In below js code what I have done is, given the display form link to the Title column of a document library.

RegisterModuleInit('/SiteAssets/Titlelink.js', updateTitle);
updateTitle();

function updateTitle() {
    var priorityFiledContext  = {};
    priorityFiledContext.Templates = {};    
    priorityFiledContext.Templates.Fields = {
        "Title": {
            "View": priorityFiledTemplate
        }
    };

    SPClientTemplates.TemplateManager.RegisterTemplateOverrides(priorityFiledContext);
}

function priorityFiledTemplate(ctx) {       
    var url = String.format('{0}&ID={1}', ctx.displayFormUrl, ctx.CurrentItem.ID);
    var ret =   "<a href='" + url + "'>" + ctx.CurrentItem.Title + "</a>";
    return ret; 
}

Hope this also helps.

0

As I can see, there's no simple way.

I solved the problem using an event receiver generating a column that includes the information to open the popup for the dispform.

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.