First off, I am rather new to CSR so I apologize for anything stupid to come!
This is Sharepoint Online.
I'm trying to use CSR, on a custom page with a filter and list view web part (doc library), to change the url of the Name column to point to the 'new experience' url, which is the 'preview' type function where it opens in browser.
The caveat is that I need it to only affect msg/eml file types, not all files. So here is the code that I have that works for ALL files. I just can't seem to figure out how to edit it to only affect msg/eml files (url changes on those file types but nothing happens on others). I cobbled this together from things I found via internet searches.
Can anyone assist?
Thanks!
(function () {
function registerRenderer() {
var ctxForm = {};
ctxForm.Templates = {};
ctxForm.Templates = {
Fields : {
'LinkFilename': { //------ Change Hyperlink of LinkTitle
View : function (ctx) {
var url = String.format('{0}', "https://mysite.sharepoint.com/demo/Subdivision%20Files/Forms/AllItems.aspx?viewpath=%2Fdemo%2FSubdivision%20Files%2FForms%2FAllItems%2Easpx&id=%2Fdemo%2FSubdivision%20Files%2F" + ctx.CurrentItem.FileLeafRef + "&parent=%2Fdemo%2FSubdivision%20Files");
return String.format(
"<a href='" + url + "'>" + ctx.CurrentItem.FileLeafRef + "</a>"
);
}
},
}
};
SPClientTemplates.TemplateManager.RegisterTemplateOverrides(ctxForm);
}
ExecuteOrDelayUntilScriptLoaded(registerRenderer, 'clienttemplates.js');
})();