I am having issues with "Name column" and its fields in libraries. I would like to iterate throuch each item and return default render value in this column in certain cases. I have tried lot of things lying here,but mostly this. For Name column I tried something like. This is JSlink issue:

function rewriteNameCoumn(ctx)
    if(ctx.CurrentItem["fsObjType"] == 1)
        //generate link for folder
        return url;


        //return default rendering for non-folder item
        return RenderFieldValueDefault(ctx);

but that does not work. Basically, the only thing I want o achieve is, when item is folder add an HTML element title = "this is folder" to it and if it is file, let it as it was. Problem with doucment library views is, that SharePoint generates each folder and file with different hyperlink properties and inline javascripts. I do not want to rebuild all of this, just because I want to add html title="this is folder" to folder name.

2 Answers 2


You have a typo, its FSObjType.

It might be easier to post-proces the DOM elements in OnPostRender and use


to get the folders

note: OneNote is a Folder as well



gets you just the folders

With multiple Views on screen you get the View Table id from the ctx object and select DOM elements from there

  • I think you are right danny. I will have to run this on post render and just add valuse to DOM :)
    – Pedro
    Jan 22, 2016 at 16:24

You can achieve this in a much easier way than the one that you mentioned. You would be required to iterate through each item of the list and then check whether it is a file or folder. Use the code given below:

var context = SP.ClientContext.get_current();
var web = context.get_web(); 
var selItems = SP.ListOperation.Selection.getSelectedItems(context); //not                      
SP.ListItem collection!
for (var index in selItems) {
 var selItem = selItems[index];
    case "0":
      console.log('File has been selected');
    case "1":
      console.log('Folder has been selected');

The main catch here is that selItem.fsObjType that is FileSystemObjecttype. This object returns 1 for file and 0 for a folder.

  • Hi Mancy, thank you for the input, but I am having issues just returning default render value for folder/item within view. I am trying to achieve this with JSlink
    – Pedro
    Jan 21, 2016 at 10:57

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.