0

I wonder if is possible to make a property of a view clickable.

For example if my list is like a list of docs (CT: Item) created with the attach file function via UI.

The view:

_____________________________________

|   ID  |   Name    |       File    |
-------------------------------------
|   01  |   t.txt   |   path\t.txt  |
-------------------------------------

I want to click on path\t.txt and open / download the file, let's assume that the path is accessible from / within sharepoint.

All this should be realized via code in VS, without SP designer.

Is it possible? What you suggest?

NB:For "via code in VS" I mean that the solution should be delivered by deploying or activating a feature, not for example, using Sharepoint Designer, that in my case is not a valid way.

  • You didn't provide enough information/details to be able to answer. Please clarify your exact scenario (one over all: what do you mean by "via code in VS", what have you done so far exactly?) – MdMazzotti Apr 23 '15 at 13:44
  • A dataview web part (DVWP) would be the easiest way to go, but that would require SPD, not VS. Are you building the list view dynamically using the SharePoint API? – Omegacron Apr 23 '15 at 17:36
0

EDIT: You tagged your question with 2010 - unfortunately this solution will only work for SharePoint 2013. But I'll leave it here for the benefit of anyone searching for a 2013 solution.

-

You can achieve this with Client Side Rendering. You will need to point the page to a JavaScript file, which will look something like this:

SP.SOD.executeFunc("clienttemplates.js", "SPClientTemplates", CSR_Setup);

function CSR_Setup() {
    var overridectx = {};
    overridectx.Templates = {};
    overridectx.Templates.Fields = {
        "File": { "View": CSR_AddFileLinks }
    };
    SPClientTemplates.TemplateManager.RegisterTemplateOverrides(overridectx);
}

function CSR_AddFileLinks(ctx) {
    var filePath = ctx.CurrentItem[ctx.CurrentFieldSchema.Name];
    return String.format('<a href="{0}">{0}</a>', filePath);
}
  • He tagged his question with 2010, meaning that CSR is NOT an option! – MdMazzotti Apr 23 '15 at 13:40
  • He did indeed! I won't delete this answer for the benefit of anyone requiring a 2013 solution. – Submits Apr 23 '15 at 13:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy