There doesn't appear to be a SharePoint 2016 Development and Programming Forum yet, so I've posted this question here.
I'm using client side rendering to add a link to a document to the Title of each item in a document library. This aspect of the rendering works just fine but I noted that the document pagination breaks when I provide a JSLink to the views of my document library.
There are a few posts I found which suggest a fix for this problem. All of them involve specifying a new function (in my example, renderFooter()) that will generate the necessary HTML to render a new pagination control at the bottom of the SP view.
Unfortunately, this fix does not work on our SP 20016 on premises server. Using a browser debugger I discovered that the two critical properties of the ListData object seen in the renderFooter() method, PrevHref and NextHref do not exist! I don't have a SP2013 server to run tests on, given that several articles on the web describe using this workaround to the missing pagination control, I'll assume that the code below does work on older servers.
Using the debugger I was unable to identify a substitute property associated with either the context object or the ListData object to use instead. Does anyone out there know how to get the PrevHref and NextHref values using SP 2016 and client side rendering?
(function () {var overrideCtx = {};
overrideCtx.Templates = {};
overrideCtx.Templates.Fields = {
"Title": { "View": overrideNameFieldTemplate }
};
overrideCtx.Templates.Footer = renderFooter;
overrideCtx.ListTemplateType = 101;
overrideCtx.BaseViewID = 1;
SPClientTemplates.TemplateManager.RegisterTemplateOverrides(overrideCtx);
})();
function overrideNameFieldTemplate(ctx) {
var title = ctx.CurrentItem.Title;
var fileRef = ctx.CurrentItem["FileRef"];
var fileLeafRef = ctx.CurrentItem["FileLeafRef"];
if (title) {
return "<a href='"+ fileRef + "'>"+ title + "</a>";
}
else {
return "<a href='"+ fileRef + "'>"+ fileLeafRef + "</a>";
}
}
function renderFooter(ctx) {
var firstRow = ctx.ListData.FirstRow;
var lastRow = ctx.ListData.LastRow;
var prev = ctx.ListData.PrevHref;
var next = ctx.ListData.NextHref;
var footerHtml = "<div class='Paging'>";
footerHtml += prev ? "<a class='ms-commandLink ms-promlink-button ms-promlink-button-enabled' href='" + prev + "'><span class='ms-promlink-button-image'><img class='ms-promlink-button-left' src='/_layouts/15/images/spcommon.png?rev=23' /></span></a>" : "";
footerHtml += "<span class='ms-paging'><span class='First'>" + firstRow + "</span> - <span class='Last'>" + lastRow + "</span></span>";
footerHtml += next ? "<a class='ms-commandLink ms-promlink-button ms-promlink-button-enabled' href='" + next + "'><span class='ms-promlink-button-image'><img class='ms-promlink-button-right' src='/_layouts/15/images/spcommon.png?rev=23'/></span></a>" : "";
footerHtml += "</div>";
footerHtml += "</div>";
return footerHtml;
}